Stage 3 Draft / July 9, 2020

Numeric separators

The grammar listed in 11.8.3 is modified as follows.

1 Numeric Literals


NumericLiteralSeparator::_ NumericLiteral::DecimalLiteral DecimalBigIntegerLiteral NonDecimalIntegerLiteral NonDecimalIntegerLiteralBigIntLiteralSuffix DecimalBigIntegerLiteral::0BigIntLiteralSuffix NonZeroDigitDecimalDigitsoptBigIntLiteralSuffix NonZeroDigitNumericLiteralSeparatorDecimalDigitsBigIntLiteralSuffix NonDecimalIntegerLiteral::BinaryIntegerLiteral OctalIntegerLiteral HexIntegerLiteral BigIntLiteralSuffix::n DecimalLiteral::DecimalIntegerLiteral.DecimalDigitsoptExponentPartopt .DecimalDigitsExponentPartopt DecimalIntegerLiteralExponentPartopt DecimalIntegerLiteral::0 NonZeroDigitDecimalDigitsopt NonZeroDigit NonZeroDigitNumericLiteralSeparatoroptDecimalDigits DecimalDigits::DecimalDigit DecimalDigitsNumericLiteralSeparatoroptDecimalDigit DecimalDigit::one of0123456789 NonZeroDigit::one of123456789 ExponentPart::ExponentIndicatorSignedInteger ExponentIndicator::one ofeE SignedInteger::DecimalDigits +DecimalDigits -DecimalDigits BinaryIntegerLiteral::0bBinaryDigits 0BBinaryDigits BinaryDigits::BinaryDigit BinaryDigitsNumericLiteralSeparatoroptBinaryDigit BinaryDigit::one of01 OctalIntegerLiteral::0oOctalDigits 0OOctalDigits OctalDigits::OctalDigit OctalDigitsNumericLiteralSeparatoroptOctalDigit OctalDigit::one of01234567 HexIntegerLiteral::0xHexDigits 0XHexDigits HexDigits::HexDigit HexDigitsNumericLiteralSeparatoroptHexDigit HexDigit::one of0123456789abcdefABCDEF

The SourceCharacter immediately following a NumericLiteral must not be an IdentifierStart or DecimalDigit.


For example: 3in is an error and not the two input elements 3 and in.

A conforming implementation, when processing strict mode code, must not extend, as described in C.1.1, the syntax of NumericLiteral to include LegacyOctalIntegerLiteral, nor extend the syntax of DecimalIntegerLiteral to include NonOctalDecimalIntegerLiteral.

1.1 Static Semantics: MV

A numeric literal stands for a value of the Number type or the BigInt type.

1.2 Static Semantics: NumericValue


DecimalBigIntegerLiteral::NonZeroDigitDecimalDigitsBigIntLiteralSuffix DecimalBigIntegerLiteral::NonZeroDigitDecimalDigitsBigIntLiteralSuffix NonZeroDigitNumericLiteralSeparatorDecimalDigitsBigIntLiteralSuffix
  1. Let n be the mathematical integer number of code points in DecimalDigits.
  2. Let mv be (the MV of NonZeroDigit × 10n) plus the MV of DecimalDigits.
  3. Return the BigInt value that represents mv.

2 ToNumber Applied to the String Type

ToNumber applied to Strings applies the following grammar to the input String interpreted as a sequence of UTF-16 encoded code points (6.1.4). If the grammar cannot interpret the String as an expansion of StringNumericLiteral, then the result of ToNumber is NaN.


The terminal symbols of this grammar are all composed of characters in the Unicode Basic Multilingual Plane (BMP). Therefore, the result of ToNumber will be NaN if the string contains any leading surrogate or trailing surrogate code units, whether paired or unpaired.


StringNumericLiteral:::StrWhiteSpaceopt StrWhiteSpaceoptStrNumericLiteralStrWhiteSpaceopt StrWhiteSpace:::StrWhiteSpaceCharStrWhiteSpaceopt StrWhiteSpaceChar:::WhiteSpace LineTerminator StrNumericLiteral:::StrDecimalLiteral NonDecimalIntegerLiteral StrBinaryLiteral StrOctalLiteral StrHexLiteral StrDecimalLiteral:::StrUnsignedDecimalLiteral +StrUnsignedDecimalLiteral -StrUnsignedDecimalLiteral StrUnsignedDecimalLiteral:::Infinity DecimalDigits.DecimalDigitsoptExponentPartopt .DecimalDigitsExponentPartopt DecimalDigitsExponentPartopt StrDecimalDigits.StrDecimalDigitsoptStrExponentPartopt .StrDecimalDigitsStrExponentPartopt StrDecimalDigitsStrExponentPartopt StrDecimalDigits:::DecimalDigit StrDecimalDigitsDecimalDigit StrExponentPart:::ExponentIndicatorStrSignedInteger StrSignedInteger:::StrDecimalDigits +StrDecimalDigits -StrDecimalDigits StrBinaryLiteral:::0bStrBinaryDigits 0BStrBinaryDigits StrBinaryDigits:::BinaryDigit StrBinaryDigitsBinaryDigit StrOctalLiteral:::0oStrOctalDigits 0OStrOctalDigits StrOctalDigits:::OctalDigit StrOctalDigitsOctalDigit StrHexLiteral:::0xStrHexDigits 0XStrHexDigits StrHexDigits:::HexDigit StrHexDigitsHexDigit

2.1 Runtime Semantics: MV

The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see 1), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in 1.1.

Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is +0 unless the first non white space code point in the String numeric literal is -, in which case the rounded value is -0. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in, unless the literal includes a StrUnsignedDecimalLiteral and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an ExponentPart and

  • it is not 0; or
  • there is a nonzero digit to its left and there is a nonzero digit, not in the ExponentPart, to its right.

A Template Literal Lexical Components


CodePoint::HexDigitsbut only if MV of HexDigits ≤ 0x10FFFF CodePointDigitsbut only if MV of HexDigits ≤ 0x10FFFF CodePointDigits::HexDigit CodePointDigitsHexDigit

B Grammar Summary

Placeholder for Annex A

C Additional ECMAScript Features for Web Browsers


C.1 Additional Syntax

C.1.1 Numeric Literals

The syntax and semantics of 1 is extended as follows except that this extension is not allowed for strict mode code:


NumericLiteral::DecimalLiteral BinaryIntegerLiteral OctalIntegerLiteral HexIntegerLiteral LegacyOctalIntegerLiteral LegacyOctalIntegerLiteral::0OctalDigit LegacyOctalIntegerLiteralOctalDigit DecimalIntegerLiteral::0 NonZeroDigitDecimalDigitsopt NonZeroDigit NonZeroDigitNumericLiteralSeparatoroptDecimalDigits NonOctalDecimalIntegerLiteral NonOctalDecimalIntegerLiteral::0NonOctalDigit LegacyOctalLikeDecimalIntegerLiteralNonOctalDigit NonOctalDecimalIntegerLiteralDecimalDigit LegacyOctalLikeDecimalIntegerLiteral::0OctalDigit LegacyOctalLikeDecimalIntegerLiteralOctalDigit NonOctalDigit::one of89