Somehow i have always assumed that floating point and integer values are processed the same except one would have a '.' character.
So for the code like this:
auto i = 0100;
std::cout << i;
I get the expected output 64
;
However, when i try the following code:
auto d = 0100.0;
std::cout << d;
I get output 100
, which is not what was expected. Now it is possible that the floating point part does not deal with a leading 0. So i have attempted something which really should have worked:
auto d = 1.0e-010;
std::cout << d;
Since exponent is actually an integer value itself, it made sense that it would understand the octal value, but the output was 1e-10
.
Is this an issue that comes from the standard or from g++ (my compiler)? How would i go about writing an octal floating point number?
Hexadecimal seem to behave differently:
auto d = 0x100.0;
Gives error: hexadecimal floating constants require an exponent
However:
auto d = 0x1e3;
std::cout << d;
produces 483
. While
auto d = 0x1e0x3;
Gives error: unable to find numeric literal operator ‘operator"" x3’