Important: The information in this document is obsolete and should not be used for new development.
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
Some examples of hexadecimal floating-point constant expressions are
- hex_digit_seq
- A sequence of hexadecimal digits. The first digit sequence must be preceded by the characters
0X
or0x
. 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 characterp
.- suffix
- One of the standard C floating-point constant suffixes such as
f
forfloat
. All floating-point constants are typedouble
unless specified otherwise.
0x1.1111p-2 /* interpreted as 1.111116 2-2 */ 0x256p35f /* interpreted as 25616 235 */