4 ms·
Stratoscope was already done a superb job explaining. But just to show why my question was not that dumb... Let's say you want to represent "two-million" in 32
by crpatino 11y ago
Stratoscope was already done a superb job explaining. But just to show why my question was not that dumb...
Let's say you want to represent "two-million" in 32bit float:
Your answer is: 0x1e8480 * 2^0.
However, I was expecting something like: 0x1.e848 * 2^X. But then "125-thousand" is 0x1.e848 * 2^Y, so how do you standardize what is the correct exponent for integers, X or Y? And how do you know there is not a pair (M,Z) != (0x1.e848, X) such that M * 2^Z is also two-million?
- dnautics 11y agothe fraction of a floating point is always "starts with on invisible 1.xxxx" so that forces unique representations for your exponent for any given number. Is it not clear why this is the case? let's take a simple case where you have one bit of fraction. exponent 0, 2^0 = 1, fraction (1)0 = 1.0b = 1 exponent 0, 2^0 = 1, fraction (1)1 = 1.1b = 1.5 exponent 1, 2^1 = 2, fraction (1)0 = 10b = 2 exponent 1, 2^1 = 2, fraction (1)1 = 11b = 3 if we have more fraction bits it looks like this: exponent 0, 2^0 = 1, fraction (1)00 = 1.00b = 1 exponent 0, 2^0 = 1, fraction (1)01 = 1.01b = 1.25 exponent 0, 2^0 = 1, fraction (1)10 = 1.10b = 1.5 exponent 0, 2^0 = 1, fraction (1)11 = 1.11b = 1.75 exponent 1, 2^1 = 2, fraction (1)00 = 10.0b = 2 exponent 1, 2^1 = 2, fraction (1)01 = 10.1b = 2.5 exponent 1, 2^1 = 2, fraction (1)10 = 11.0b = 3 exponent 1, 2^1 = 2, fraction (1)11 = 11.1b = 3.5 So for any given exponent multiplication with a fraction with an invisible bit creates products that are hemmed between 1.0x2^n and 2.0*2^n so there's no collisions between any pair (e,f) in your representation.