nx_money.nx
buildroot/runtime/nx_money.nx
about
nx_money.nx -- R1 of THE NISHI FINANCIAL ECOSYSTEM engine: the NO-FLOAT money substrate.
Money is exact i64 MINOR UNITS (cents). Rates are fixed-point scaled by MNY_RATE_SCALE (1e9).
All arithmetic is integer -- floats are WRONG for money (0.1 + 0.2 != 0.3), so this is correctness,
not doctrine. Provides exact add/sub/neg, rounded division (floor / half-up / banker's half-even),
scaled-rate application (interest), APR->periodic, percent constructor, and [-]D.CC formatting.
Foundation for the ledger (R2), debt/amortization (R4), audit (R5), optimizer (R7).
PRECONDITION on mny_apply_rate: |amount * rate_scaled| < 2^63 (true for all realistic personal-finance
amounts; 128-bit-safe widening for extreme values is the R1b hardening rung). license_tier: ORIGINAL
dependencies 1 imports · 31 importers
diagram shows first 10 each side; +0 more imports, +21 more importers in the complete lists below.
imports: nx_syscalls.nx
imported by: nx_adhd.nxnx_adhd_gate.nxnx_bills.nxnx_bills_gate.nxnx_bills_store_gate.nxnx_browser_buyguard.nxnx_browser_buyguard_gate.nxnx_card_rewards.nxnx_climbout.nxnx_climbout_docs.nxnx_climbout_docs_gate.nxnx_climbout_gate.nxnx_climbout_real.nxnx_climbout_real_gate.nxnx_debt_gate.nxnx_debt_payoff.nxnx_doc_extract_gate.nxnx_fin_audit.nxnx_fin_audit_gate.nxnx_fin_dispute.nxnx_fin_dispute_gate.nxnx_fin_finance.nxnx_fin_finance_gate.nxnx_fin_ledger.nxnx_fin_ledger_gate.nxnx_fin_rules_gate.nxnx_finance_web.nxnx_intake_handler_gate.nxnx_money_gate.nxnx_purchase.nxnx_purchase_gate.nx
structs
| none |
consts
| 11 | const MNY_RATE_SCALE: i64 = 1000000000 |
| 12 | const RND_FLOOR: i64 = 0 |
| 13 | const RND_HALF_UP: i64 = 1 |
| 14 | const RND_HALF_EVEN: i64 = 2 |
functions
| 16 | func mny_add(a: i64, b: i64) -> i64 { return a + b } |
| 17 | func mny_sub(a: i64, b: i64) -> i64 { return a - b } called by 1: main |
| 18 | func mny_neg(a: i64) -> i64 { return 0 - a } called by 1: main |
| 21 | func mny_div_floor(num: i64, den: i64) -> i64 called by 1: mny_div_round |
| 30 | func mny_div_round(num: i64, den: i64, mode: i64) -> i64 called by 12: adhd_hours_costadhd_pct_of_goalbl_monthlycr_rewards_annualcr_point_bpscr_breakeven_balance+6 calls 1: mny_div_floor |
| 51 | func mny_apply_rate(amount: i64, rate_scaled: i64, mode: i64) -> i64 |
| 56 | func mny_rate_monthly(apr_scaled: i64) -> i64 |
| 62 | func mny_rate_from_pct(pct_num: i64, pct_den: i64) -> i64 called by 13: bg_load_profilemaincr_interest_annualcr_breakeven_balancecor_dashboardmain+7 calls 1: mny_div_round |
| 67 | func mny_wdec(out: *u8, pos: i64, v: i64) -> i64 |
| 80 | func mny_format(amount: i64, out: *u8) -> i64 |