contents.gifindex.gifprev1.gifnext1.gif

2.1.2.1 Numeric literals

A numeric literal is a character string selected from the digits, the plus sign, the minus sign, and the decimal point. Numeric literals may contain up to 18 digits. The following rules govern the formation of numeric literals.

1. A literal must contain at least one digit.

2. It must contain no more than one sign character and, if one is used, it must be the leftmost character of the string.

3. A literal must not contain more than one decimal point. The decimal point is treated as an assumed decimal point and may appear anywhere within the literal except as the rightmost character.

If a literal conforms to the rules for formation of a numeric literal, but is enclosed in quotation marks, it is a nonnumeric literal.

Floating Point Literals

1. A floating point literal has the following format:

[  +   ]    k.m      [  E  ]    [  +   ]  n
[ - ] [ e ] [ - ]

In the above:

gt490000.gif "k. m" represents a number with at least one digit.

gt490000.gif "n" represents one or more digits.

gt490000.gif If the functions of the decimal point and comma are switched with DECIMAL IS COMMA, then "k.m" will be "k,m".

Here are a few examples of floating point numbers:

-12.345e12

.0123E-6

123.E1

2. Floating-point literals in the Procedure Division are stored internally as USAGE DOUBLE.

3. The legal range of floating-point values is determined by the target machine. If you express a literal that is out of range for a particular machine, the runtime reports a warning message and substitutes the closest boundary value--either zero or the maximum floating-point value for the machine.

4. On some computers, floating point computations may give imprecise results. This is a hardware limitation--some floating point numbers cannot be precisely represented on some machines.