Expand description
Exact decimal (SQL DECIMAL/NUMERIC, money).
f64 is not a decimal type and never was. It cannot represent 0.1,
and past ~15 significant digits it silently rounds โ so an invoice
total of 12345678901234567.89 comes back as 12345678901234568,
with no error, no warning, and no way for the caller to tell. That is
the single most damaging thing a knowledge graph can do to financial
data, so this type never touches binary floating point.
Representation is an i128 of unscaled digits plus a decimal scale
โ 12.3400 is unscaled = 123400, scale = 4. Scale is preserved
rather than trimmed: in SQL, DECIMAL(10,4) carrying 12.3400 is
not the same column value as 12.34, and a round-trip that quietly
drops the trailing zeros has changed the data.
i128 holds 38 significant digits, which covers DECIMAL(38, s) โ
the maximum precision of Postgres, MySQL, SQL Server, and Oracle
alike. Input beyond that is rejected (None) rather than truncated.
Structsยง
- Decimal
- An exact base-10 number:
unscaled / 10^scale.