User Tools

Site Tools


decimal_signed_packed_decimal_.htm
Navigation:  Language Reference > 3 - Variable Declarations > Data Types >====== DECIMAL (signed packed decimal) ====== Previous pageReturn to chapter overviewNext page
label DECIMAL(length [,places] [,initial value]) [,DIM( )] [,OVER( )] [,NAME( )] [,EXTERNAL] [,DLL]
[,STATIC] [,THREAD] [,AUTO] [,PRIVATE] [,PROTECTED]

blk2blue.jpg

DECIMAL 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

      +9,999,999,999,999,999,999,999,999,999,999

length A required numeric constant containing the total number of decimal digits (integer and fractional portion combined) in the variable. The maximum length is 31.
places 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.
DIM Dimension the variable as an array.
OVER Share a memory location with another variable.
NAME Specify an alternate, “external” name for the field.
EXTERNAL Specify the variable is defined, and its memory is allocated, in an external library. Not valid within FILE, QUEUE, or GROUP declarations.
DLL Specify the variable is defined in a .DLL. This is required in addition to the EXTERNAL attribute.
STATIC Specify the variable's memory is permanently allocated.
THREAD Specify memory for the variable is allocated once for each execution thread. Also implicitly adds the STATIC attribute on Procedure Local data.
AUTO Specify the variable has no initial value.
PRIVATE Specify the variable is not visible outside the module containing the CLASS methods. Valid only in a CLASS.
PROTECTED 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).

Example:

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

            END

           END

decimal_signed_packed_decimal_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1