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 3 - Numerics in PowerPC Assembly Language
Chapter 13 - Assembly-Language Numeric Conversions


Conversions From Double to Single Format

To convert a double floating-point number to single format, either store the double number in single format (listed here and described in Chapter 11) or use the frsp instruction.
frspConvert double to single format.
stfsStore in single format.
stfsuStore in single format and update.
stfsuxStore in single format and update indexed.
stfsxStore in single format indexed.

For store instructions, the conversion takes place automatically. The store instructions raise no floating-point exceptions and treat zeros, NaNs, and Infinities like any other value. The frsp instruction converts a double-format number to single format and then places it in the last half of a floating-point register. Use the frsp instruction immediately before using the single form of any arithmetic instruction. The following example performs single-precision addition on a number that has been converted to single format using the frsp instruction.

lfs   f1,d(r1)    #load single format number into f1
                  #conversion to double format is automatic
frsp  f1,f1       #f1 is now in single format
fadds f0,f1,f1    #so that it can be added as single format number
Note
The frsp instruction might raise floating-point exceptions. See the Motorola PowerPC 601 RISC Microprocessor User's Manual for more information.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996