Hacker News new | ask | show | jobs
by forrestthewoods 746 days ago
> Over 99% of all values represented in [0,1] are in [0,0.5].

Is that true if you exclude denormals?

2 comments

Yes. The floats in [0,1) come in blocks: [1/2, 1), [1/4, 1/2), [1/8, 1/4), etc. There are 2^23 floats in each block and there are 127 blocks. The reason there are so many floats in [0, 0.5] is only one block, [1/2, 1), is outside that range. If you exclude the denormals (which have a special block that stretches to 0, [0, 1/2^126)), you still just excluded a single block.
Ahhh that makes sense. That’s a much more clear explanation. Thanks!
Yes. Subnormals start at <1.0 * 2^(-126). Between [1.0 * 2^(-126), 0.5] there are 125x more distinct float values than there are in the range [0.5, 1].