The library follows the JSON specification (RFC 8259) for number representation.
JSON Number Syntax
Numbers are represented in base 10 using decimal digits. A number consists of:
- An optional minus sign (
-). - An integer component.
- An optional fraction part (a decimal point followed by one or more digits).
- An optional exponent part (starting with
E or e, followed by an optional + or - sign and one or more digits).
Constraint: Leading zeros are not allowed in the integer component.
Interoperability and Precision Limits
While the JSON spec allows for arbitrary precision, this library (and most standard implementations) targets IEEE 754 binary64 (double precision) for interoperability.
When working with numbers, be aware of the following:
- Precision/Range Risks: Using numbers like
1E400 or extremely long decimals (e.g., 3.141592653589793238462643383279) may cause interoperability issues if the receiving software cannot handle the magnitude or precision. - Exact Integer Range: To ensure exact numeric agreement across different implementations, keep integers within the range of $[-2^{53}+1, 2^{53}-1]$.