Hexadecimal floating-point literals

Real hexadecimal floating-point constants, which are a C99 feature, consist of the following:
  • a hexadecimal prefix
  • a significant part
  • a binary exponent part
  • an optional suffix
The significant part represents a rational number and is composed of the following:
  • a sequence of hexadecimal digits (whole-number part)
  • an optional fraction part
The optional fraction part is a period followed by a sequence of hexadecimal digits.
The exponent part indicates the power of 2 to which the significant part is raised, and is an optionally signed decimal integer. The type suffix is optional. The full syntax is as follows:

Hexadecimal floating-point literal syntax

Read syntax diagramSkip visual syntax diagram0x0Xdigit_0_to_fdigit_0_to_F.digit_0_to_fdigit_0_to_Fexponentdigit_0_to_fdigit_0_to_F.exponentdigit_0_to_fdigit_0_to_FexponentfFlL
Exponent
Read syntax diagramSkip visual syntax diagrampP+-digit_0_to_9
The suffix f or F indicates a type of float, and the suffix l or L indicates a type of long double. If a suffix is not specified, the floating-point constant has a type double. You can omit either the whole-number part or the fraction part, but not both. The binary exponent part is required to avoid the ambiguity of the type suffix F being mistaken for a hexadecimal digit.