Decimal multiplication
For decimal multiplication, the precision and scale of the result depends on the precision and scale of the operands.
For multiplication, the precision of the result is MIN(n,p+p'),
and the scale is MIN(n,s+s'). n is
31 if DEC31 is in effect or if the precision of at least one operand is greater
than 15. Otherwise, n is 15.
If both operands have a precision greater than 15, the operation is performed
using a temporary copy of the operand with the smaller precision. If the operands
have the same precision, the second operand is selected. If more than 15 significant
digits are needed for the integral part of the copy, the statement's execution
is ended and an error occurs. Otherwise, the copy is converted to a number
with precision 15, by truncating the copy on the right. The truncated copy
has a scale of MAX(0,S-(P-15)),
where P and S are the original precision
and scale. If, in the process of truncation, one or more nonzero digits are
removed, SQLWARN7 in SQLCA is set to W, indicating loss of precision.
When both operands have a precision greater than 15, the foregoing formulas
for the precision and scale of the result still apply, with one change: for
the operand selected as the copy, use the precision and scale of the truncated
copy; that is, use 15 as the precision and MAX(0,S-(P-15)) for
the scale.
10000000000000000000000000. * 1will
cause overflow because the number of leading zeros in the 31-digit representation
of the large number and the precision of the small number are both 5 (see Arithmetic with an integer and a decimal operand).