DECIMAL

[UNSIGNED] DECIMALn [ _y ]

UDECIMALn [ _y ]

A packed decimal value of n total digits. If the _y value is present, the y defines the number of decimal places in the value. There can be at most 32 leading digits and 32 fractional digits.

If the UNSIGNED keyword is omitted, the rightmost nibble holds the sign. Unsigned decimal declarations may be contracted to use the optional UDECIMALn syntax instead of UNSIGNED DECIMALn.

Using exclusively DECIMAL values in computations invokes the Binary Coded Decimal (BCD) math libraries (base-10 math), allowing up to 32-digits of precision (which may be on either side of the decimal point).

Example:

DECIMAL5_2 MyDecimal := 123.45;
        //five total digits with two decimal places
      
OutputFormat199 := RECORD
   UNSIGNED DECIMAL9 Person.SSN;
        //unsigned packed decimal containing 9 digits,
        // occupying 5 bytes in a flat file
        
UDECIMAL10 Person.phone;
        //unsigned packed decimal containing 10 digits,
        // occupying 5 bytes in a flat file
     
END;