Hi,
I am designing a class called Dynamic that can store many different types: a null, a boolean, a 48-bit signed integer, a 64-bit floating point, or a pointer to one of a few defined types. This object contains only one data member: a double.
In order to do that, I use the fact that there are many way to represent a NaN, and only 2 NaN needs to exist in the standard (this trick is known as NaN boxing and is heavily used in some javascript engines). If we look at the bits used to represent a NaN, we have (on a little endian machine):
[first 48 bits][4 bits][1111][1111][111|0]
The eleven 1 are placed at the exponent, and the 0 is placed at the sign bit. A double is a NaN when the eleven exponent bits are equal to 1 and one of the first 52 bits is not equal to 0.
Some experiments show that quiet NaN are represented by [000...000][0001][1111][1111][1110] and signaling NaN are represented by [000...000][0010][1111][1111][1110].
Is it possible to have other NaNs with Intel compilers and the Intel libraries (MKL, SVML, etc) ?