ReadonlyscaleNumber of decimal places.
ReadonlyunitsValue as an integer, scaled by 10 ** scale.
Static ReadonlyONEStatic ReadonlyZERODivide, rounding to scale decimal places.
Division cannot be exact, so the scale is explicit rather than inferred: an accidental default would be a silent precision decision.
Re-express with a different number of decimal places.
Round to scale decimal places.
Fixed-point text with exactly scale decimals.
Lossy; only for display and diagnostics.
Canonical decimal text, as written into the XML.
Number of significant digits, for checking totalDigits facets.
StaticfromBuild a decimal from an exact representation.
A number is accepted for convenience and taken as its shortest
round-trippable decimal string, so Decimal.from(1.5) is 1.5; a
non-finite number is rejected. But a float cannot represent every decimal
exactly, and a value whose magnitude renders in exponential notation (such
as 1e-7 or 1e21) is not accepted as a number. Pass such values — and
any amount where exactness matters — as a string.
An exact decimal, held as a scaled integer.
The NAV schemas make binary floating point untenable:
MonetaryTypeallows 18 significant digits,QuantityTypeallows 22 with 10 decimal places, and a VAT rate of0.27has no exactdoublerepresentation. Since NAV rejects a batch whose lines fail to reconcile with its summary, every amount is carried through as an exact value and rounded only where the rules say to round.