Financial Primitives
Zero-Float Monetary Precision
Why Trivio enforces minor currency units and BigInt intermediate precision.
The Danger of IEEE-754 Floats
In standard JavaScript and TypeScript, 0.1 + 0.2 === 0.30000000000000004. In large-scale payment processing, accumulating fractional cent errors across millions of transactions leads to ledger imbalances and reconciliation failures.
precision.tstypescript
// ❌ Prohibited floating-point calculation:
// 10000.00 * 0.029 = 289.99999999999994 (Floating point drift!)
// ✅ Trivio deterministic integer calculation:
const grossMinor = 1000000n; // 10,000.00
const rateBps = 290n; // 2.90%
const percentageFee = (grossMinor * rateBps + 5000n) / 10000n; // Exact Round-Half-Up divisionRounding Policy
Trivio implements Round-Half-Up (roundHalfUpDiv) as its core arithmetic rounding policy (trivio-mdr-v1-half-up), adding half the divisor (5000n for basis points divisor 10000n) before integer division to guarantee deterministic commercial banking behavior without floating-point error.
