Decimal
Fixed-precision decimal values for exact, financial-grade arithmetic.
A Decimal is a fixed-precision decimal value for cases that demand exact numbers — especially financial calculations, where floating-point approximation can introduce errors. A Decimal stores an exact value with a defined precision and scale.
Unlike a standard floating-point Number, a Decimal does not approximate: 0.1m is exactly one-tenth, not the nearest binary fraction.
Syntax
A Decimal is written as a number with the m suffix. It requires a leading digit and, if a decimal point is present, at least one digit after it. Scientific notation is not supported.
decimal = ["-" | "+"] digit+ [ "." digit+ ] "m"
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"Structural characters
m
Decimal suffix
U+006D
Marks the value as a Decimal
0–9
Digits
Multiple
Decimal digits
.
Decimal point
U+002E
Separates the integer and fractional parts
-
Minus sign
U+002D
Negative value
Valid forms
---
123.45m, 123m, 0.001m, -789.01m, 0m, 0.0m123.45m— fractional decimal123m— integer decimal0.001m— leading zeros preserved-789.01m— negative decimal0m,0.0m— zero, with and without a scale
Precision and scale
Each Decimal carries a precision (the total number of significant digits) and a scale (the number of digits after the decimal point):
A schema can constrain these; see Decimal.
Invalid forms
A Decimal requires a leading digit and, with a decimal point, a trailing digit. Scientific notation is rejected:
A doubled suffix is not an error. 123.45mm is an open string, by the same rule that makes 12mm one: nothing in it announced a decimal, because the m that would have done so is followed by more text. See A number, or a word that begins with a digit?.
A plain
123.45(nom) is a valid Number, not a Decimal — themsuffix is what selects fixed precision.
Preservation of structure
Internet Object preserves:
Exact decimal precision and scale
Syntactic fidelity as written, except that an explicit
+sign is not preserved
It does not interpret:
Rounding behavior for operations
Currency or unit semantics
Those semantics belong to the schema, the validator, or the application.
See Also
Numeric Values — all numeric forms
Number — standard floating-point numbers
BigInt — arbitrary-precision integers
Last updated
Was this helpful?
