SQL/MX 3.2.1 Programming Manual for C and COBOL (H06.26+, J06.15+)
Host Variables in C/C++ Programs
HP NonStop SQL/MX Release 3.2.1 Programming Manual for C and COBOL—663854-005
3-28
Numeric Data
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.
For example, if the numerator is NUMERIC (70, 10) and the denominator is
NUMERIC (50, 20), the precision and the scale of the result will be calculated
as follows:
Magnitude of the numerator is 70 - 10 = 60.
Scale of the numerator is 10.
Magnitude of the denominator is 50 - 20 = 30.
Scale of the denominator is 20.
Therefore, Scale of quotient = 10 + 30 = 40.
Therefore, Magnitude of quotient = 60 + 20 = 80.
Hence, precision of the quotient = 80 + 40 = 120.
GNU GMP library for BigNum
The user program uses the GNU GMP library for extensive number processing. You
can convert the new BigNum external binary format into the GMP format by using GMP










