User Tools

Site Tools


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

blk2blue.jpg

PDECIMAL A packed decimal floating point number.

Format:               magnitude                 ±

       | …………………………….. | . |

Bits:  127                                    4   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.

PDECIMAL declares a variable length packed decimal signed numeric variable in the Btrieve and IBM/EBCDIC type of format. Each byte of an PDECIMAL holds two decimal digits (4 bits per digit). The right-most byte holds the sign in its low-order nibble (0Fh or 0Ch = positive, 0Dh = negative) and one decimal digit. Therefore, PDECIMAL variables always contain a fixed “odd” number of digits (PDECIMAL(10) and PDECIMAL(11) both use 6 bytes).

Example:

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

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

                                            ! signed packed decimal

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

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

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

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

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

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

Record       RECORD

Count8        PDECIMAL(5,0),NAME('Counter')  !Declare with external name

            END

           END

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