Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Units in the last place definition

I am reading What Every Computer Scientist Should Know About Floating Point.

The concept of ulps seems pretty straightforward. However, in an early example, the author makes a claim (in section Guard Digits)

That, when comparing the calculated value: (0.02 x 10) to the true value (0.17) of a calculation (10.1 - 9.93), that the error is 30ulps.

By the formula presented earlier in the paper, the error should be:

|0.02 - 0.017| * 100 = 0.3ulps, which makes sense to me.

Clearly, I am missing something rather important here.

like image 795
Kay Avatar asked May 14 '18 13:05

Kay


2 Answers

While illustrating the subtraction, Goldberg shows the result as .02 × 101. This keeps the exponent that was used in the inputs and the subtraction. However, it is not the normalized exponent of the result.

In the example, the precision p is 3 digits. Thus, the computed result .02 × 101 could be represented as 2.00 × 10−1, and the exact mathematical result would be 1.70 × 10−1. The ULP of both of these representations is .01 × 10−1, and the computed result differs from the mathematical result by 30 ULP.

like image 148
Eric Postpischil Avatar answered Oct 23 '22 20:10

Eric Postpischil


Having 2 digits doesn't mean that 1 ulp is 0.01. The whole point of the unit is that it's relative to the precision of a particular number. 0.02 is 2.00 * 10-2; 0.017 is 1.70 * 10-2; there are 30 steps between 1.70 and 2.00 as

Err = | 2.00 - 1.70 | (10²)
    = 30 ulps

(Since these two results happen to have the same exponent, we're spared the difficulty of deciding which one "defines" the ulp, but we are not defining it by 10.1 or 9.93.)

like image 42
Sneftel Avatar answered Oct 23 '22 21:10

Sneftel