Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 1 - The PowerPC Numerics Environment
Chapter 5 - Conversions


Converting Between Floating-Point Formats

PowerPC Numerics supports conversions between all three of its floating-point data formats. This section describes these conversions.

Converting Between Single and Double Formats

The PowerPC microprocessor directly supports the single and double formats and conversions between them. When a single format number is converted to a double format number, the conversion is exact.

When a double format number is converted to a single format number, it is rounded to the closest single value in the current rounding direction. The conversion might raise the exceptions shown in Table 5-2.
Table 5-2 Double to single conversion: Possible exceptions
ExceptionRaised when
Inexact Significand requires > 24 bits of precision
Overflow Exponent > 127
Underflow Exponent < -126

Converting Between Single and Double-Double Formats

When a single format number is converted to a double-double format number, the result is exact. The following actions take place (as shown in Figure 5-1):

  1. The single number is converted to double format.
  2. The resulting double number is placed in the head of the double-double number.
  3. The tail of the double-double number is set to 0.
  4. The sign of the tail is set to the sign of the head.

Figure 5-1 Single to double-double conversion

When a double-double number is converted to a single number, the following actions take place (as shown in Figure 5-2):

  1. The head and tail of the double-double number are added together.
  2. The sum is rounded to the closest single value in the current rounding direction.

Figure 5-2 Double-double to single conversion

The double-double to single conversion might raise the exceptions shown in Table 5-3.
Table 5-3 Double-double to single conversion: Possible exceptions
ExceptionRaised when
Inexact Significand requires > 24 bits of precision
Overflow Exponent > 127
Underflow Exponent < -126

Converting Between Double and Double-Double Formats

When a double format number is converted to a double-double format number, the result is exact. The following actions take place:

  1. The double number is placed in the head of the double-double number.
  2. The tail of the double-double number is set to 0.
  3. The sign of the tail is set to the sign of the head.

When a double-double number is converted to a double number, the following actions take place:

  1. The head and tail of the double-double number are added together.
  2. The sum is rounded to the closest double value in the current rounding direction.

The conversion might raise the inexact exception if the significand requires more than 53 bits of precision.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996