Ada Numeric Literals and Underscore

This is from the Ada online directory: http://www.adaic.org/resources/add_content/standards/05rm/RM.pdf (section 2.3)

A decimal_literal is a numeric_literal in the conventional decimal notation (that is, the base is ten). 
Syntax 
decimal_literal ::= numeral [.numeral] [exponent] 
**numeral ::= digit {[underline] digit}** 
exponent ::= E [+] numeral | E – numeral
digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
An exponent for an integer literal shall not have a minus sign. 
Static Semantics 
**An underline character in a numeric_literal does not affect its meaning.** The letter E of an exponent can be 
written either in lower case or in upper case, with the same meaning.

If i do

my_literal ::= 123_456;

What does underscore mean? He says that this does not affect the meaning . Then what is it for? I am sure there is a simple answer, but reading and re-updating did not help me.

+5
source share
1 answer

For the same reason, for example, commas ( ,) in currency or [other large] numbers: grouping. In this way:    

Million : Constant:= 1_000_000;

In addition, you can use it in combination with the base parameter as a setting for masking:

Type Bit is Range 1..8;
SubType Byte is Interfaces.Unsigned_8;
Type Masks is Array(Positive Range <>) of Byte;

Mask_Map : Constant Masks(Bit):=
    (
        2#0000_0001#,
        2#0000_0010#,
        2#0000_0100#,
        2#0000_1000#,
        2#0001_0000#,
        2#0010_0000#,
        2#0100_0000#,
        2#1000_0000#
    );

, , Mask_Map or, and xor . , , , - , , , 1..PARAMETER'Size.

+7

All Articles