When a value of packed decimal type is converted to floating type, if the value being converted is outside the range of values that can be represented, then the behavior is undefined. If the value being converted is within the range of values that can be represented, but cannot be represented exactly, the result is truncated. When a float or a double is converted to a packed decimal with smaller precision, the fractional part of the float or the double will be truncated.
The following example shows the conversion from a packed decimal type to a floating point type.
Figure 280. ILE C Source to Convert a Packed Decimal to a Floating Point
|
The output is as follows:
+--------------------------------------------------------------------------------+ | f1=123.449997 | | f2=-123456.125000 | | Press ENTER to end terminal session. | +--------------------------------------------------------------------------------+
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.