C++17 allows defining floating point constants in hexadecimal format like
double d1 = 0x1.2p3; // 9.0
double d2 = 0x1.86Ap+16 // 100000.0
In hexadecimal floating point constants the mantissa and exponent is separated using the letter p|P
.
Why C++ standard committee decided to use the letter p|P
instead of any other letter?
They could not have used the normal e|E
notation in hex floating point constant because letter e|E
is part of hexadecimal digit. But they could have used letter g|G
which is usually used in printf
format specifier for floating point value, or any other letter. Is there any specific reason for using the letter p
?