DECIMAL (signed packed decimal)

Top  Previous  Next


label DECIMAL(length [,places] [,initial value]) [,DIM( )] [,OVER( )] [,NAME( )] [,EXTERNAL] [,DLL]






A packed decimal floating point number.


Format:  ±                      magnitude

      | . | ................................. |

Bits: 127 124                                  0

Range: -9,999,999,999,999,999,999,999,999,999,999 to




A required numeric constant containing the total number of decimal digits (integer and fractional portion combined) in the variable. The maximum length is 31.


A numeric constant that fixes the number of decimal digits in the fractional portion (to the right of the decimal point) of the variable. It must be less than or equal to the length parameter. If omitted, the variable will be declared as a math based integer. As a result, when places is omitted or zero, fractional values are rounded up.

initial value

A numeric constant. If omitted, the initial value is zero, unless the AUTO attribute is present.


Dimension the variable as an array.


Share a memory location with another variable.


Specify an alternate, "external" name for the field.


Specify the variable is defined, and its memory is allocated, in an external library. Not valid within FILE, QUEUE, or GROUP declarations.


Specify the variable is defined in a .DLL. This is required in addition to the EXTERNAL attribute.


Specify the variable's memory is permanently allocated.


Specify memory for the variable is allocated once for each execution thread. Also implicitly adds the STATIC attribute on Procedure Local data.


Specify the variable has no initial value.


Specify the variable is not visible outside the module containing the CLASS methods. Valid only in a CLASS.


Specify the variable is not visible outside base CLASS and derived CLASS methods. Valid only in a CLASS.


DECIMAL declares a variable length packed decimal signed numeric variable. Each byte of a DECIMAL holds two decimal digits (4 bits per digit). The left-most byte holds the sign in its high-order nibble (0 = positive, anything else is negative) and one decimal digit. Therefore, DECIMAL variables always contain a fixed "odd" number of digits (DECIMAL(10) and DECIMAL(11) both use 6 bytes).


Count1 DECIMAL(5,0)                         !Declare three-byte signed packed decimal

Count2 DECIMAL(5),OVER(Count1)              !Declare OVER the three-byte

                                           !signed packed decimal

Count3 DECIMAL(5,0),DIM(4)                  !Declare it an array of 4 decimals

Count4 DECIMAL(5,0,5)                       !Declare with initial value

Count5 DECIMAL(5,0),EXTERNAL                !Declare as external

Count6 DECIMAL(5,0),EXTERNAL,DLL            !Declare as external in a .DLL

Count7 DECIMAL(5,0),NAME('SixCount')        !Declare with external name


Storage STRING(16)

Count8  DECIMAL(31,0),OVER(Storage)         !Declare with OVER attribute

ExampleFile FILE,DRIVER('TopSpeed')         !Declare a file

Record       RECORD

Count9        DECIMAL(5,0),NAME('Counter')  !Declare with external name