(Contents)(Previous)(Next)

DECIMAL

The data type 'decimal' may be used for the declaration of variables to which fixed point numbers in packed decimal representation are assigned. The number of decimal digits is defined by <dcmldigits> ( <= 15 ), the number of fractional digits is defined by <dcmlfract> ( <= <dcmldigits> ). The default is 5, 0. These specifications are used during runtime for the conversion of SQL parameters and database columns of the type 'fixed'. The usage of the data type 'decimal' exactly correlates the value ranges of parameters to those of database columns, so that rounding and overflow errors are not possible. The representation in memory is done in a byte array, where the decimal digits are stored in successive half bytes. The sign is coded in the rightmost (least significant) half byte ('+' as 0XC and '-' as 0XD). The remaining positions occupy the digits in right-justified representation.

The precompiler replaces the declaration of 'decimal' variables by a structure declaration:

DECIMAL {n, f} v; is replaced by

struct {char arr[m];} v, where

m = (n + 2)/ 2 (integer division) applies.

Examples of valid 'decimal' declarations are:

DECIMAL {} a, *b, c [20]; /* variable declaration

with the default values 5, 0 */

DECIMAL {6} d; /* d is a variable with 6

decimal digits */

DECIMAL LONGDEC {15, 2}; /* LONGDEC is a tag for decimal numbers

with 15 digits and 2 fractional

digits */

DECIMAL LONGDEC e, f; /* LONGDEC is used for the declaration of

the variables e and f */


(Contents)(Previous)(Next)