In C, if I want a floating point literal x to be in hexadecimal form and have an exponential value, it will be denoted as this:
float x = 0X2aE+10;
Where the 0x is used to denote it's in hexadecimal, and the 2a for the hexadecimal characters, and the E+10 for the number into ten to the power ten. However, will the compiler know it's not 2aE that's representing the hexadecimal digits (since hexadecimal uses a to e for 10-15) and +10 is just adding ten to the number? And if it doesn't, what's the fix?
0X2aE+10
is a valid preprocessor token that does not translate into a valid C token, hence the compilation error. C99 Hexadecimal floating point numbers useP
orp
as the exponent marker, as in:Which has the value
0x2a * 1024
->43008
.For those who do not know about preprocessing numbers:
If you see e.g. this floating point literal reference you will see that hexadecimal floating point values need the
p
orP
infix to denote the exponent.So the definition should look like
Hex floats use
p
as the exponent marker:That's actually a
double
value, though. If you want afloat
literal, you need anf
suffix: