SQL/MX 3.2 Programming Manual for C and COBOL (H06.25+, J06.14+)

Host Variables in C/C++ Programs
HP NonStop SQL/MX Release 3.2 Programming Manual for C and COBOL663854-002
3-24
Numeric Data
SQL_BignumSign
The SQL_BignumSign function retrieves the sign of a BigNum value:
void SQL_BignumSign( Int16 * sign, BignumExt value, UInt16
valueLen )
The sign operand is set to 0 for positive BigNum values and -1 for negative BigNum
values.
Considerations for BigNum Arithmetic function
When you declare a BigNum host variable (NUMERIC (20, 3)), SQL/MX translates the
value to a short data type array in the C language. The short data type array has no
scale. The scale is implicit and must be handled in the application. For example, you
want to assign the value 1234 to the BigNum host variable using the BigNum
assignment functions. If you place the value 1234 directly, the decimal point is implicit.
Therefore, the actual value interpreted by the SQL/MX is 1.273. To place the value
1273 into the table, the value 1237000 must be assigned to the BigNum assignment
functions.
Precision, Magnitude, and Scale of BigNum Arithmetic Results
Precision is the maximum number of digits in the BigNum host variable. Magnitude is
the number of digits to the left of the decimal point. Scale is the number of digits to the
right of the decimal point.
For example, if a host variable is declared as NUMERIC (128, 5), the Precision is 128,
the Magnitude is 123, and the Scale is 5.
If the operator is addition (+) or subtraction (-),
The resulting precision is the maximum of the magnitudes of the operands,
plus the scale of the result, plus 1.
If the operator is multiplication (*),
The resulting scale is the sum of the scales of the operands.
The resulting precision is the total of the sum of the magnitudes of the
operands and the scale of the result.
If the operator is division (/),
The resulting scale is the sum of the scale of the numerator and the magnitude
of the denominator.
The resulting magnitude is the sum of the magnitude of the numerator and the
scale of the denominator.
The resulting precision is the sum of the magnitude of the result and the scale
of the result.