Search code examples
floating-pointfloating-accuracyieee-754fpu

Range of floating-point number


I was reading "What every computer scientist should know about floating-point arithmetic" and came across something that I don't understand. Paper asserts that for given B and E (base and exponent) maximum value of normalized floating point number is B x B^E and minimum value is B^E. I don't understand the maximum part of it.

Let's take for example this case where B=10 P=3 and E=4. Minimum value this number can take is 1.00 x 10^4, which equals to 10^4 (B^E). Maximum value is 9.99 x 10^4 which is close to B x B^E but isn't quite equal to it. Paper doesn't mention any approximation so I'm assuming that I'm doing something wrong. Can anyone explain why maximum value is B x B^E


Solution

  • You have to look at it in context. That section is talking about relative errors when approximating a number by its closest floating-point representation. There are numbers that are closer to B·B^E than to B·B^E - ulp(B^E), and those numbers would be converted to B·B^E. Analyzing the error using the next exponent would be a problem, because the source number would be out of the range and the ulp would be different. It makes more sense to analyze it within the closed range [B^E, B·B^E].

    For example, for B=10, P=3, E=4, the number 9.996·10^4 is closer to 10.00·10^4 than to 9.99·10^4, and using an ulp of 0.01·10^5 for error analysis would be a mistake, because 9.996·10^4 belongs to a different interval than [10^5, 9.99·10^5].