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 2 - The PowerPC Numerics C Implementation
Chapter 7 - Numeric Data Types in C


Efficient Type Declarations

MathLib contains two floating-point type definitions, float_t and double_t in the header Types.h. If you define a variable to be float_t or double_t, it means "use the most efficient floating-point format for this architecture." Table 7-2 shows the definitions for float_t and double_t for both the PowerPC and 680x0 architecture.
Table 7-2 float_t and double_t types
Architecturefloat_t typedouble_t type
PowerPCfloatdouble
680x0long doublelong double

For the PowerPC architecture, the most natural format for computations is double, but the architecture allows computations in single precision as well. Therefore, for the PowerPC architecture, float_t is defined to be float (single precision) and double_t is defined to be double. The 680x0 architecture is based on an 80-bit double-extended format (known as extended) and performs all computations in this format regardless of the type of the operands. Therefore, float_t and double_t are both long double (extended precision) for the 680x0 architecture.

If you declare a variable to be type double_t and you compile the program as a PowerPC application, the variable is of type double. If you recompile the same program as an 680x0 application, the variable is of type long double.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996