DECIMAL type related macros

Decimals are defined by an encoded length - the total number of significant digits (precision), and the significant digits to the right of the decimal (scale).

The following macros handle decimal length:

Table 1. Decimal type related macros
Macro Description
DECLEN(m,n) Calculates the minimum number of bytes necessary to hold a decimal ( m = precision, n = scale)
DECLENGTH(length) Calculates the minimum number of bytes necessary to hold a decimal, given the encoded length
DECPREC(size) Calculates a default precision, given the size (the number of bytes used to store a number)
PRECTOT(length) Returns the precision from an encoded length
PRECDEC(length) Returns the scale from an encoded length
PRECMAKE(p,s) Returns the encoded decimal length from a precision and scale