Purpose
A numeric literal is a numeric value that can be expressed as a fixed-point or floating-point constant.
First Usage
Fixed-Point Numeric Literals
A fixed-point numeric literal is a 1- to 16-digit number with an optional decimal point. The decimal point cannot be in the first or last position of the constant. If the constant does not contain a decimal point, it is an integer.
Fixed-point numeric literals are treated internally as packed decimal numbers and can be used whenever the process command syntax specifies a user-supplied numeric literal.
A fixed-point numeric literal can be signed or unsigned. A unary plus (+) or unary minus (-) can immediately precede the first digit or can be separated from the digit by one or more spaces. The numeric literal is positive if no sign is provided.
Example 1: Fixed-point numeric literal as a value for comparison
The following example compares the value in the field VALUE-2 to the fixed-point numeric literal -13.65:
IF VALUE-2 EQ -13.65
THEN
.
.
.
Example 2: An integer as a fixed-point numeric literal
The following example moves the integer 31456 to the field VALUE-1:
MOVE 31456 TO VALUE-1.
Second Usage
Floating-Point Numeric Literals
A floating-point numeric literal is a numeric literal whose value is expressed as a mantissa, which represents the number, followed by an exponent (characteristic), which determines the actual decimal position of the number.
All floating-point numeric literals are treated internally as internal short or long floating-point numbers, depending on the size of the mantissa. Floating-point numeric literals can be used whenever the process command syntax specifies an arithmetic expression, the name of a user-defined data field, or a user-supplied numeric constant.
Format of a Floating-Point Numeric Literal:
1.2564E3
In this example, 1.2564 is the mantissa.
1.2564E3
1.2564E3
In this example, 3 is the characteristic.
The value of the floating-point constant is the product of the mantissa, and ten raised to the power of the characteristic.
A floating-point numeric literal can be signed or unsigned. A unary plus (+) or unary minus (-) can immediately precede the first digit or can be separated from the digit by one or more spaces. If no sign is provided, the numeric literal is positive.
Examples
The following examples show the floating-point numeric literals and their fixed point equivalents.
|
Floating-point numeric literal |
Fixed-point equivalent |
|---|---|
|
1.2574E3 |
1257.4 |
|
1.2574E-3 |
0.0012574 |
|
-1.2574E20 |
-125740000000000000000 |
|
Copyright © 2014 CA.
All rights reserved.
|
|