For the complete documentation index, see llms.txt. This page is also available as Markdown.

Number

Standard 64-bit IEEE 754 floating-point numbers.

A number is a 64-bit double-precision floating-point value conforming to IEEE 754. Numbers are scalar values used to express integers, fractional values, and special numeric constants.

Numbers support several representations: decimal, the alternative bases (binary, octal, hexadecimal), scientific notation, and the special values NaN and Inf.

Syntax

A number can be written in several forms:

number = ["-" | "+"] (
    decimalNumber
  | binaryNumber
  | octalNumber
  | hexNumber
  | scientificNumber
) | specialValue

decimalNumber    = digit+ [ "." digit* ] | "." digit+
binaryNumber     = "0b" binaryDigit+
octalNumber      = "0o" octalDigit+
hexNumber        = "0x" hexDigit+
scientificNumber = ( digit+ [ "." digit* ] | "." digit+ ) ("e" | "E") ["-" | "+"] digit+
specialValue     = "NaN" | "Inf" | "-Inf" | "+Inf"

digit       = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
binaryDigit = "0" | "1"
octalDigit  = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7"
hexDigit    = digit | "A" | "B" | "C" | "D" | "E" | "F" | "a" | "b" | "c" | "d" | "e" | "f"

Structural characters

Symbol
Name
Unicode
Description

09

Digits

Multiple

Decimal digits

.

Decimal point

U+002E

Separates the integer and fractional parts

-

Minus sign

U+002D

Negative value

+

Plus sign

U+002B

Explicit positive value (not preserved on output)

e / E

Exponent

Multiple

Scientific-notation exponent

0b

Binary prefix

Multiple

Begins a binary number

0o

Octal prefix

Multiple

Begins an octal number

0x

Hex prefix

Multiple

Begins a hexadecimal number

Valid forms

Decimal numbers

Decimal numbers may be integers or fractional values, with an optional sign. A leading or trailing decimal point is allowed (.5 and 5.).

Alternative bases

Numbers can be written in binary, octal, or hexadecimal. The prefix is case-insensitive, and hex digits may be upper or lower case.

Scientific notation

Scientific notation uses e or E (case-insensitive) for the exponent, which may be signed.

Equivalent forms

The same value can be written in several bases and notations:

All five values above are 42.

Invalid forms

The following are genuine syntax errors (the parser reports an error):

Implementation status (beta)

The reference implementation is currently lenient with some malformed numeric tokens. These are tracked as implementation issues; a conformant parser SHOULD reject them rather than accept or coerce them:

  • An incomplete exponent is accepted instead of rejected: 1e and 1e+ both yield 1.

  • A token that begins like a number but is ill-formed falls back to an open string instead of raising an error: 0b12"0b12", 1.2.3"1.2.3", 1.23ee4"1.23ee4".

Preservation of structure

Internet Object preserves:

  • The chosen notation (decimal, binary, octal, hex, scientific)

  • Whitespace (non-significant)

  • Syntactic fidelity as written, except that an explicit + sign is not preserved

It does not interpret:

  • Mathematical relationships between values

  • Precision beyond IEEE 754

  • Domain-specific numeric constraints

Those semantics belong to the schema, the validator, or the application.

See Also

Last updated

Was this helpful?