Numeric Variables
ANSI
Numeric variables are defined as a BOOLEAN, FORM, or INTEGER type. BOOLEAN or FORM variables contain numeric data in a valid decimal number format, while INTEGER variables only contain whole, unsigned numeric data in a machine specific format. Either may be used in any mathematical instruction though FORM variables lend themselves to accounting functions and INTEGER variables lend themselves to high-speed counting or loop functions.
Note the following:
The format of a numeric variable is set at definition. Whenever a new value is assigned, it is aligned to this definition.
The physical length of a FORM variable may not exceed 32 bytes (including the decimal) while an INTEGER variable is limited to 4 bytes.
If the numeric variable is a FORM and contains a decimal, the results of any arithmetic instruction are aligned to the decimal.
When arithmetic instructions involving FORMs exceed the size of the destination variable, truncation, rounding or both may occur.
Truncation may occur on either the right (least significant) or left (most significant). Left truncation usually sets the OVER flag.
Rounding is a form of right-truncation. Rounding uses a rounded digit (least significant digit not lost), a rounding digit (most significant digit lost), and lost digit(s) (integers beyond the rounding digit). Two forms of rounding are supported. The first is the traditional method that was used on Datapoint DOS systems. The second method is the method specified by the ANSI standard for PL/B. The default rounding method is the first method. The ANSI rounding is performed when there is an environment variable "PLB_ROUND=ANSI" specified. The only difference is when the rounded digit is a five and all lost digits are zero.
If the rounding (next least significant) digit being lost is zero to four, the rounded (next most significant) digit remains unchanged.
In the traditional method, if the rounding digit is five and the lost (next least significant) digit(s) is zero then positive numbers increment the rounded digit by one. Negative numbers leave the rounded digit unchanged. In the ANSI method in all cases the rounded digit is incremented by one.
If the rounding digit is five and the lost digit(s) is greater than zero or if the rounding digit is greater than five, the rounded digit is incremented by one.
When arithmetic instructions involving INTEGERs exceed the size of the destination variable, truncation occurs on the most significant bytes.
BOOLEAN variables may only contain a value of zero (FALSE) or one (TRUE).
See Also: Data Definitions
![]() |