Rules regarding numeric assignment are as follows.
- The whole part of a number may be altered when converting it to floating-point.
A single-precision floating-point field can only contain seven decimal digits.
Any whole part of a number that contains more than seven digits is altered
due to rounding. A double-precision floating point field can only contain
16 decimal digits. Any whole part of a number that contains more than 16 digits
is altered due to rounding.
- The whole part of a number is never truncated. If necessary, the
fractional part of a number is truncated. If the number, as converted, does
not fit into the target host variable or column, a negative SQLCODE is returned.
- Whenever a decimal, numeric, or integer number is assigned to a
decimal, numeric, or integer column or host variable, the number is converted,
if necessary, to the precision and scale of the target. The necessary number
of leading zeros is added or deleted; in the fractional part of the number,
the necessary number of trailing zeros is added, or the necessary number of
trailing digits is eliminated.
- When an integer or floating-point number is assigned to a decimal
or numeric column or host variable, the number is first converted to a temporary
decimal or numeric number and then converted, if necessary, to the precision
and scale of the target.
- When a halfword binary integer (SMALLINT) with 0 scale is converted
to decimal or numeric, the temporary result has a precision of 5 and a scale
of 0.
- When a fullword binary integer (INTEGER) is converted to decimal
or numeric, the temporary result has a precision of 11 and a scale of 0.
- When a double fullword binary integer (BIGINT) is converted to
a decimal or numeric, the temporary result has a precision of 19 and a scale
of 0.
- When a floating-point number is converted to decimal or numeric,
the temporary result has a precision of 31 and the maximum scale that allows
the whole part of the number to be represented without loss of either significance
or accuracy.