A numeric separator is a non-digit character allowed to appear in integer literal syntax to improve readability. They do not add/remove any semantics or change any values; they are only a writing tool.
The underscore _ is the symbol used as the numeric separator. Underscores can be placed in integer literals to separate groups of digits in the literal, as a comma or full stop would be used in some written languages.
Examples:
the speed of light, 299,792,458 m/s: 299_792_458
a credit card number: 0000_1234_5678_9999
binary or hexadecimal digit groupings: 0100_0101, 33_66_99
Numeric separators may not be adjacent to each other, nor may they appear at the start or end of the literal. The following tokens are not well-formed and should fail lexical analysis (a lexical error should be thrown):
11__22__33
123_123_
There are future plans to include identifiers, which may begin with an underscore. Thus while the token _123123 is not an integer literal (having the value 123,123), it will be a well-formed token representing an identifier.
Allow numeric separators between digits in integer literals.
A numeric separator is a non-digit character allowed to appear in integer literal syntax to improve readability. They do not add/remove any semantics or change any values; they are only a writing tool.
The underscore
_
is the symbol used as the numeric separator. Underscores can be placed in integer literals to separate groups of digits in the literal, as a comma or full stop would be used in some written languages.Examples:
299_792_458
0000_1234_5678_9999
0100_0101
,33_66_99
Numeric separators may not be adjacent to each other, nor may they appear at the start or end of the literal. The following tokens are not well-formed and should fail lexical analysis (a lexical error should be thrown):
11__22__33
123_123_
There are future plans to include identifiers, which may begin with an underscore. Thus while the token
_123123
is not an integer literal (having the value 123,123), it will be a well-formed token representing an identifier.