• 0 Posts
  • 8 Comments
Joined 1 year ago
cake
Cake day: June 4th, 2023

help-circle




  • From the documentation (emphasis mine):

    If the floating literal begins with the character sequence 0x or 0X, the floating literal is a hexadecimal floating literal. Otherwise, it is a decimal floating literal.

    For a hexadecimal floating literal, the significand is interpreted as a hexadecimal rational number, and the digit-sequence of the exponent is interpreted as the (decimal) integer power of 2 by which the significand has to be scaled.

    double d = 0x1.4p3; // hex fraction 1.4 (decimal 1.25) scaled by 2^3, that is 10.0

    You can find the full documentation here: cppreference.com

    So in your example 0x1P1 means 116 * 2^(110) = 2