2.4.1 Decimal Literals

25
Dec

Decimal Literals

1 {literal (decimal)} A decimal_literal is a numeric_literal in the conventional decimal notation (that is, the base is ten). 

Syntax

2 decimal_literal ::= numeral [.numeral] [exponent]
3 numeral ::= digit {[underline] digit}
4 exponent ::= E [+] numeral | E - numeral
4.1/2 digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

5 An exponent for an integer literal shall not have a minus sign. 

5.a Ramification: Although this rule is in this subclause, it applies also to the next subclause. 

Static Semantics

6 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.

6.a Ramification: Although these rules are in this subclause, they apply also to the next subclause. 

7 An exponent indicates the power of ten by which the value of the decimal_literal without the exponent is to be multiplied to obtain the value of the decimal_literal with the exponent

Examples

8 Examples of decimal literals: 

9     12     0     1E6    123_456    --  integer literals
9.0   12.0   0.0   0.456  3.14159_26 --  real literals

Wording Changes from Ada 83

9.a We have changed the syntactic category name integer to be numeral. We got this idea from ACID. It avoids the confusion between this and integers. (Other places don't offer similar confusions. For example, a string_literal is different from a string.)

[aada]

Alexis Ada

We may implement a pragma to allow the syntax 1E-1 to write 0.1, although this is not legal Ada, it makes sense to accept such. (The legal syntax is 1.0E-1)

The largest accepted numbers are limited by the length of a literal which is limited to 4096 characters (see 14 and 14.a in §2.2). Obviously 1E999... followed by 4094 '9' characters is already a quite large number (i.e. 10 power (10 power 4094)) Very large numbers are likely to break the compilation with an out of heap error.

[/aada]