nx_damages_lib.nx
buildroot/runtime/nx_damages_lib.nx
about
nx_damages_lib.nx -- PREJUDGMENT INTEREST / money damages over time. Integer-exact, composes nx_sol.
A money judgment is rarely just the principal: statutes award prejudgment interest from the date of loss
(accrual) to the date of judgment. Getting it right means an EXACT day count (not an approximation) and the
correct convention -- simple vs annual compounding, at a declared statutory rate. This organ REUSES the
exact proleptic-Gregorian day engine from nx_sol (composition, not a re-implementation) for the day count,
then does the interest in exact integer minor units.
FAIL-CLOSED: a judgment date before the accrual date, a negative principal, or a negative rate returns
DMG_BAD -- you never compute interest on an impossible interval. The year basis is a DECLARED constant
(statutes differ: 365 vs 360); it is not buried (Rule 11).
SCALE ENVELOPE (declared): principal * annual_bp * days fits i64 for principal up to ~9e10 minor units at
bp<=1e4, days<=1e4. license_tier: ORIGINAL No hw writes (Rule 26). LIB.
dependencies 1 imports · 2 importers
imports: nx_sol_lib.nx
imported by: nx_damages_gate.nxnx_legal_svc.nx
structs
| none |
consts
| 18 | const DMG_YEAR_DAYS: i64 = 365 // declared day-count basis (statute-configurable; 360 is the alternative) |
| 19 | const DMG_BP_FULL: i64 = 10000 |
| 20 | const DMG_BAD: i64 = 0 - 2000000002 |
functions
| 23 | func dmg_days_between(y1: i64, m1: i64, d1: i64, y2: i64, m2: i64, d2: i64) -> i64 |
| 31 | func dmg_simple_interest(principal: i64, annual_bp: i64, days: i64) -> i64 |
| 39 | func dmg_compound_interest(principal: i64, annual_bp: i64, years: i64) -> i64 |
| 53 | func dmg_total_award(principal: i64, interest: i64) -> i64 |