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 - Appendixes
Appendix D - FPCE Recommendations for Compilers


Hexadecimal Floating-Point Constants

The FPCE technical report expands the definition of a floating-point constant in C to include hexadecimal floating-point constants. This format makes it easier to represent constants equal to or near arbitrary powers of 2 because they can be represented in hexadecimal instead of having to be converted to decimal.

A hexadecimal floating-point constant has the form

0xhex_digit_seq[.hex_digit_seq]p[+|-]binary_exponent[suffix]
which is interpreted as

hex_digit_seq.hex_digit_seq×2(+|-)binary_exponent

hex_digit_seq
A sequence of hexadecimal digits. The first digit sequence must be preceded by the characters 0X or 0x. The hexadecimal point and the digit sequence appearing after it are optional.
binary_exponent

A decimal integer representing a power of 2. The exponent may or may not have a sign, but it must be preceded by the character p.
suffix
One of the standard C floating-point constant suffixes such as f for float. All floating-point constants are type double unless specified otherwise.
Some examples of hexadecimal floating-point constant expressions are

0x1.1111p-2    /* interpreted as 1.111116  2-2 */
0x256p35f      /* interpreted as 25616  235 */

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996