[top] [prev] [next]

Numeric literals

Numeric literals denote constant non-negative integers or reals. The types of these literals are INTEGER, 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 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]


[Modula-3 home page]

m3-request@src.dec.com
Last modified on Wed Apr  3 09:39:02 PST 1996 by heydon
     modified on Mon Apr 18 14:04:55 PDT 1994 by kalsow