
![[PREVIOUS]](/image.pl?url=http%3a%2f%2farchive.adaic.com%2fstandards%2f83lrm%2fhtml%2flrm-prev.gif&f=jpg&w=240)
![[UP]](/image.pl?url=http%3a%2f%2farchive.adaic.com%2fstandards%2f83lrm%2fhtml%2flrm-up.gif&f=jpg&w=240)
![[NEXT]](/image.pl?url=http%3a%2f%2farchive.adaic.com%2fstandards%2f83lrm%2fhtml%2flrm-next.gif&f=jpg&w=240)
There are two classes of numeric literals: real literals and integerliterals. A real literal is a numeric literal that includes a point; aninteger literal is a numeric literal without a point. Real literals arethe literals of the type universal_real. Integer literals are the literalsof the type universal_integer.
numeric_literal ::= decimal_literal | based_literal
References:literal,universal_integer type,universal_real type.
Rationale references:2.1 Lexical Structure
Sub-topics:
![[UP]](/image.pl?url=http%3a%2f%2farchive.adaic.com%2fstandards%2f83lrm%2fhtml%2flrm-up.gif&f=jpg&w=240)
![[NEXT]](/image.pl?url=http%3a%2f%2farchive.adaic.com%2fstandards%2f83lrm%2fhtml%2flrm-next.gif&f=jpg&w=240)
A decimal literal is a numeric literal expressed in the conventionaldecimal notation (that is, the base is implicitly ten).
decimal_literal ::= integer [.integer] [exponent] integer ::= digit {[underline] digit} exponent ::= E [+] integer | E - integerAn underline character inserted between adjacent digits of a decimalliteral does not affect the value of this numeric literal. The letter E ofthe exponent, if any, can be written either in lower case or in upper case,with the same meaning.
An exponent indicates the power of ten by which the value of the decimalliteral without the exponent is to be multiplied to obtain the value of thedecimal literal with the exponent. An exponent for an integer literal mustnot have a minus sign.
Examples:
12 0 1E6 123_456 -- integer literals 12.0 0.0 0.456 3.14159_26 -- real literals 1.34E-12 1.0E+6 -- real literals with exponent
Notes:
Leading zeros are allowed. No space is allowed in a numeric literal, noteven between constituents of the exponent, since a space is a separator. Azero exponent is allowed for an integer literal.
References:digit,lower case letter,numeric literal,separator,space character,upper case letter.
![[PREVIOUS]](/image.pl?url=http%3a%2f%2farchive.adaic.com%2fstandards%2f83lrm%2fhtml%2flrm-prev.gif&f=jpg&w=240)
![[UP]](/image.pl?url=http%3a%2f%2farchive.adaic.com%2fstandards%2f83lrm%2fhtml%2flrm-up.gif&f=jpg&w=240)
A based literal is a numeric literal expressed in a form that specifies thebase explicitly. The base must be at least two and at most sixteen.
based_literal ::= base # based_integer [.based_integer] # [exponent] base ::= integer based_integer ::= extended_digit {[underline] extended_digit} extended_digit ::= digit | letterAn underline character inserted between adjacent digits of a based literaldoes not affect the value of this numeric literal. The base and theexponent, if any, are in decimal notation. The only letters allowed asextended digits are the letters A through F for the digits ten throughfifteen. A letter in a based literal (either an extended digit or theletter E of an exponent) can be written either in lower case or in uppercase, with the same meaning.
The conventional meaning of based notation is assumed; in particular thevalue of each extended digit of a based literal must be less than the base.An exponent indicates the power of the base by which the value of the basedliteral without the exponent is to be multiplied to obtain the value of thebased literal with the exponent.
Examples:
2#1111_1111# 16#FF# 016#0FF# -- integer literals of value 255 16#E#E1 2#1110_0000 # -- integer literals of value 224 16#F.FF#E+2 2#1.1111_1111_111#E11 -- real literals of value 4095.0
References:digit,exponent,letter,lower case letter,numeric literal,upper case letter.
Style Guide references:3.1.2 Numbers,3.2.5 Constants and Named Numbers,7.2.6 Precision of Constants
![[Ada Information Clearinghouse]](/image.pl?url=http%3a%2f%2farchive.adaic.com%2fstandards%2f83lrm%2fhtml%2fsmall_adaic_logo.gif&f=jpg&w=240)
Address any questions or comments toadainfo@sw-eng.falls-church.va.us.