1

I believe there is a tiny mistake in the paper "What Every Computer Scientist Should Know About Floating-Point Arithmetic".

It claims that

A less common situation is that a real number is out of range, that is, its absolute value is larger than
http://img219.imageshack.us/img219/7396/screenshot2011052714105.png http://img219.imageshack.us/img219/7396/screenshot2011052714105.png.

This is almost exact, the maximum representable floating point number is slightly less than that, and the real number is out of range when it is larger than
http://img707.imageshack.us/img707/9236/screenshot2011052714045.png http://img707.imageshack.us/img707/9236/screenshot2011052714045.png

Right?

deceze
525k89 gold badges806 silver badges954 bronze badges
asked May 27, 2011 at 12:16
4
  • 2
    Perhaps "larger than" should be "larger than or equal to". Commented May 27, 2011 at 12:29
  • Yes that would be correct as well, but not as precise. Commented May 27, 2011 at 12:40
  • Looks right to me. Also, you can ditch the 1 + from your expression if you just make the sum start at i=0. Commented May 27, 2011 at 18:20
  • 1
    Wait, that's not right. Beta is the base, right? So for example, if beta=10, you want a number like .9999 * 10^n. I think you need a (beta-1) factor in your sum. Commented May 27, 2011 at 18:23

1 Answer 1

1

I cannot be bothered with images, so I will write b for "beta" and m for "e_max".

So say b is the base, p is the precision, and m is the max exponent.

Then I think the expression you want is:

(1 - b^(-p)) * b^m

For example, for base-10 with 4 digits of precision and a max exponent of 12, this gives:

.9999 * 10^12

...which is correct.

Note that this is not exactly right for IEEE floating point, because there the leading "1" bit is implicit. And I vaguely recall some oddities when the exponent is all 1's.

answered May 27, 2011 at 18:31
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.