4. Numbers
Readable Object Notation

Numbers use decimal notation, with the ASCII digits 0 through 9. An integer consists of an optional minus sign followed by digits. Its first digit is nonzero unless the integer is zero itself. A decimal point followed by one or more digits adds a fractional part. An exponent begins with e or E, followed by an optional sign and one or more digits. A decimal point or exponent makes the literal a floating-point number, even when its value is a whole number.

RON
[0 42 -17 1.0 0.125 -2.5 1e3 6.02e23 1E-3]
→
Canonical RON
[0 42 -17 1.0 0.125 -2.5 1000.0 6.02e+23 0.001]
→
{} JSON
[
  0,
  42,
  -17,
  1.0,
  0.125,
  -2.5,
  1e3,
  6.02e23,
  1E-3
]

Table of Contents

4.1. Canonical numbers ↑

Integers and floats are distinct RON types, even when they have the same mathematical value. Integers are stored as signed i64 and format in decimal without leading zeroes. Integer negative zero formats as 0.

Floats are finite IEEE 754 binary64 values. A decimal float input is rounded to binary64 before formatting. Float formatting follows the number serialization rules in RFC 8785, with one RON-specific addition: if the result has neither a decimal point nor an exponent, append .0 so it remains a float on reparse. Positive and negative floating-point zero both format as 0.0.

RON
[
  -0
  -0.0
  1
  1.0
  1e0
  1e3
  1e-7
  1e21
  9007199254740993
  9007199254740993.0
]
→
Canonical RON
[0 0.0 1 1.0 1.0 1000.0 1e-7 1e+21 9007199254740993 9007199254740992.0]
→
{} JSON
[
  -0,
  -0.0,
  1,
  1.0,
  1e0,
  1e3,
  1e-7,
  1e21,
  9007199254740993,
  9007199254740993.0
]

A nonzero float literal that rounds to zero is an underflow error. A float that overflows to infinity and an integer outside the i64 range are also errors. Representable subnormal floats remain valid. JSON has no prescribed numeric bit width, so consumers must support these ranges to preserve every RON number.

RON
[
  0.0
  -0.0
  5e-324
  -5e-324
  1.7976931348623157e+308
  -1.7976931348623157e+308
  9007199254740992.0
  -9007199254740992.0
  2.9514790517935283e+20
  9.999999999999997e+22
  1e+23
  1.0000000000000001e+23
  9.999999999999997e+20
  9.999999999999999e+20
  1e+21
  9.999999999999997e-07
  1e-06
  333333333.3333332
  333333333.33333325
  333333333.3333333
  333333333.3333334
  333333333.33333343
  -3.3333333333333333e-06
  1424953923781206.2
]
→
Canonical RON
[0.0 0.0 5e-324 -5e-324 1.7976931348623157e+308
 -1.7976931348623157e+308 9007199254740992.0 -9007199254740992.0 295147905179352830000.0
 9.999999999999997e+22 1e+23 1.0000000000000001e+23 999999999999999700000.0 999999999999999900000.0
 1e+21 9.999999999999997e-7 0.000001 333333333.3333332 333333333.33333325
 333333333.3333333 333333333.3333334 333333333.33333343 -0.0000033333333333333333
 1424953923781206.2]
→
{} JSON
[
  0.0,
  -0.0,
  5e-324,
  -5e-324,
  1.7976931348623157e+308,
  -1.7976931348623157e+308,
  9007199254740992.0,
  -9007199254740992.0,
  2.9514790517935283e+20,
  9.999999999999997e+22,
  1e+23,
  1.0000000000000001e+23,
  9.999999999999997e+20,
  9.999999999999999e+20,
  1e+21,
  9.999999999999997e-07,
  1e-06,
  333333333.3333332,
  333333333.33333325,
  333333333.3333333,
  333333333.3333334,
  333333333.33333343,
  -3.3333333333333333e-06,
  1424953923781206.2
]

A leading plus sign, leading zeroes, hexadecimal prefixes, and digit separators are not part of this number syntax. Text that does not match the number syntax is a bare string, including the words NaN and Infinity.

RON
[012 +2 0xff 1_000 NaN Infinity]
→
Canonical RON
[012 +2 0xff 1_000 NaN Infinity]
→
{} JSON
[
  "012",
  "+2",
  "0xff",
  "1_000",
  "NaN",
  "Infinity"
]