[top] [prev] [next]

Numeric literals

Numeric literals denote constant non-negative integers or reals. The types of these literals are INTEGER, LONGINT, REAL, LONGREAL, and EXTENDED.

A literal INTEGER has the form base_digits, where base is one of "2", "3", ..., "16", and digits is a non-empty sequence of the decimal digits 0 through 9 plus the hexadecimal digits A through F. The "base_" can be omitted, in which case base defaults to 10. The digits are interpreted in the given base. Each digit must be less than base. For example, 16_FF and 255 are equivalent integer literals.

If no explicit base is present, the value of the literal must be at most LAST(INTEGER). If an explicit base is present, the value of the literal must be less than 2^Word.Size, and its interpretation uses the convention of the Word interface. For example, on a sixteen-bit two's complement machine, 16_FFFF and -1 represent the same value.

A literal LONGINT has the form integer L, where integer has the same form as a literal INTEGER. If no explicit base is present, the value of the literal must be at most LAST(LONGINT). If an explicit base is present, the value of the literal must be less than 2^Long.Size, and its interpretation uses the convention of the Long interface. For example, the LONGINT having the value zero would be written 0L.

A literal REAL has the form decimal E exponent, where decimal is a non-empty sequence of decimal digits followed by a decimal point followed by a non-empty sequence of decimal digits, and exponent is a non-empty sequence of decimal digits optionally beginning with a + or -. The literal denotes decimal times 10^exponent. If "E exponent" is omitted, exponent defaults to 0.

LONGREAL and EXTENDED literals are like REAL literals, but instead of E they use D and X respectively.

Case is not significant in digits, prefixes or scale factors. Embedded spaces are not allowed.

For example, 1.0 and 0.5 are valid, 1. and .5 are not; 6.624E-27 is a REAL, and 3.1415926535d0 a LONGREAL.

[top] [prev] [next]