liveBook · Manning

Hexadecimal floating-point constant

As explained in Modern C, Third Edition

A hexadecimal floating-point literal is a C floating-point literal written with a hexadecimal significand and a binary exponent introduced by P or p.

A hexadecimal floating-point constant combines a hexadecimal significand with an exponent introduced by P or p. Its general form is 0XhPe, interpreted as h × 2^e: h uses hexadecimal digits, while e remains a decimal exponent. This notation is useful when specifying floating-point values with exact representations. section 5.3

Reading a hexadecimal floating-point constant

0x1.7aP-13 means the hexadecimal fraction 1.7a multiplied by 2 to the power −13. The hexadecimal significand supplies the value’s digits; P-13 supplies a binary scaling factor, not a power of 16. section 5.3

float double long double
Literal 0.2F 0.2 0.2L
Value 0x1.9999’9AP-3F 0x1.9999’9999’9999AP-3 0xC.CCCC’ CCCC’ CCCC’ CCDP-6L

Compare hexadecimal floating-point constants with float, double, and long double suffix forms. section 5.3

How Modern C, Third Edition covers it

How deep it goes
Defines the significand, P exponent, and numerical interpretation, but does not discuss compiler implementation or portability details.
Examples
Uses 0x1.7aP-13 and type-suffixed hexadecimal constants for float, double, and long double.
What it assumes
Assumes familiarity with hexadecimal digits and decimal floating-point notation.
What you can do after
Evaluate a hexadecimal significand scaled by a power of two.
How it connects
Connects hexadecimal floating-point literals with decimal floating-point literals, hexadecimal notation, and binary exponents.

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, Third Edition. The section links point to the parts of the book it draws on.