Saturday, May 25, 2024

[djtfvrnt] sigil numbers

IEEE 754 floating point can represent infinities and Not a Number without crashing (in contrast to integers, which cannot represent those):

float infinity = 1/0.0;
float NaN = 0/0.0;
float negative_infinity = -1/0.0;

the denominator of 0.0 not 0 is needed to avoid a compile-time warning (gcc 7.5.0). 1.0/0 and 0.0/0 also cause the warning.

the infinities may be useful for algorithms which require an initialization value larger or smaller than any value that will be seen in the input, for example, finding the maximum of an array.

I can't think of any numerical use case for NaN.  there are apparently many encodings (bit strings) that are NaN, so maybe useful for steganography.

No comments :