NaN gets generated instead of syntax error
In decimal notation the presence of 'e' requires that it is followed by the numerical value of the exponent:
> 1e;
Warning: syntax error.
The last symbol read has been "e".
Will skip input until next semicolon after the unexpected token. May leak memory.
> 1e-;
Warning: syntax error.
The last symbol read has been "e".
Will skip input until next semicolon after the unexpected token. May leak memory.
In contrast, as mentioned in the documentation, in hexadecimal notation, the 'p' serves as a marker to discriminate between full hexadecimal notation and hexadecimal dump of a single or double. Therefore, the following syntax is valid:
> 0x1p;
1
However, the following syntax should not be valid and nevertheless it is currently interpreted as NaN, which, according to me, should be considered as a bug:
> 0x1p-;
Warning: Rounding occurred when converting the hexadecimal constant "0x1p-" to floating-point with 165 bits.
If safe computation is needed, try to increase the precision.
NaN