Hacker News new | ask | show | jobs
by dagw 2492 days ago
A lot of them were NaN.

I seem to recall that ~0.5% of the IEEE 32 bit float space is NaN.

1 comments

A NaN is any value where the 7-bit (for 32-bit floats) exponent is all 1s, except for +/-inf. So a quick approximation is that 1/128 ~= 0.78% of the space is NaN.

That means there's 25 bits that we can change while still being either a NaN or an inf. But two of those values are infs, so we need to remove them. Divide that by the entire range and we have (2^25 - 2) / 2^32 = 16777215/2147483648, or about 0.78124995%.