The convertNumeric128() function

Converts an input numeric value from its current storage size, precision, and scale to a 128-bit numeric with a new precision and scale.

Description

The function has three forms of syntax:
CNumeric128 convertNumeric128(int32 value, int curPrec, int curScale, 
int desiredPrec, int desiredScale);
CNumeric128 convertNumeric128(int64 value, int curPrec, int curScale, 
int desiredPrec, int desiredScale);
CNumeric128 convertNumeric128(CNumeric128 value, int curPrec, int 
curScale, int desiredPrec, int desiredScale);

value specifies the integer part of the input numeric, which can be either a 32-bit, 64-bit, or 128-bit value.

curPrec and curScale specify the current precision and scale for the input numeric value.

desiredPrec and desiredScale specify the new precision and scale for the converted numeric value. For a 128-bit numeric, the desiredPrec value can range from 19 to 38, and the desiredScale value can range from 0 to (38-desiredPrec). If your wanted precision is in the range of 1 to 9, use the convertNumeric32 function, or if the wanted precision is in the range of 10 to 18, use the convertNumeric64 function. This helps to ensure that you select the right storage size for the resulting integer portion of the numeric.

Returns

The function returns a 128-bit integer that is compatible with the wanted precision and scale values.

Throws

For a description of the exceptions, see the exceptions for The convertNumeric32() function.