liveBook · Manning

Hexadecimal floating-point constant

As explained in Modern C

A hexadecimal floating-point constant is a C floating-point literal written with hexadecimal significand digits and a binary power exponent.

Consider 0x1.99999AP-3: its hexadecimal significand is combined with a binary power exponent, making the literal correspond closely to a floating-point binary representation. section 5.3

A precise spelling for an approximate value

The decimal constant 0.2 may be stored as approximately 0.2000000000000000111. The hexadecimal constant 0x1.99999AP-3 represents approximately 0.20000000298, while 0xC.CCCCCCCCCCCCCCDP-6 represents approximately 0.200000000000000000003. Their spellings look distant, but their values are close. On most modern architectures, hexadecimal floating-point constants with few digits exactly match their literal values. section 5.3

TAKEAWAY: A floating-point literal has value, type, and binary representation.

  • Use a trailing f or F for float, l or L for long double; without a suffix, the constant has type double. section 5.3

How Modern C covers it

How deep it goes
Explains syntax, approximation, representation, and suffix-selected types, but does not develop floating-point internals.
Examples
Uses 0x1.99999AP-3, 0xC.CCCCCCCCCCCCCCDP-6, and typed variants of 0.2.
What you can do after
Evaluate hexadecimal floating-point spellings and select float, double, or long double with suffixes.
How it connects
Connects floating-point constants with binary representation, rounding, approximation, and floating-point types.

Also explained in

Compare how 2 books explain hexadecimal floating-point constant →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.