Hacker News new | ask | show | jobs
by llm_trw 695 days ago
Floating points numbers have a fix precision mantissa, and a fixed precision exponent.

So you have xxxxx E xxx as an example of a 5 bit mantissa and 3 bit exponent.

You have 2^5 floating point numbers for each possible exponent.

So no, you're wrong. For exponent 0 you have 2^5, and for exponent 1, 10 and 11 you then have the same. The exponent 0b (0d) then contain the same number of possible floating mantissas as does 1b (1d), 10b (2d) and 11b(3d). Which means that there are as many mantissas between [0,1) as there are between [1,3)

2 comments

> for exponent 1, 10 and 11 you then have the same

Right. But the exponent is signed as well, so you have the same number of exponent values mapping to values between -1 and 1 (roughly exponent values from -127 to -1) as to all other values (between -inf and -1 and between 1 and inf), exponent values from 1 to 126.

why do you think the range [0,1) is represented by one exponent?
Because it is half the range expressed in 1 bit of exponent, the same way that [1,3) is half the range expressed in 2 bits of exponent. I'd used [0,2) and [2,4) but that would confuse people used to thinking in base 10, which includes the OP author apparently.