Prashant Pandey
Prashant Pandey

Reputation: 4642

Units In The Last Place - Intuition

I am reading David Goldberg's "What Every Computer Scientist Must Know About Floating Point Numbers" and came across the section on ULPs. He gives an example:

Actual result : 0.0314 = 3.14 x 10 -2

Closest FP no: 3.12 x 10 -2

So, ULP = (3.14 - 3.12) x 10 2 = 2

However, I am not able to develop an intuition of what this actually means and need some help. What does 'units' mean here?

Upvotes: 1

Views: 496

Answers (1)

Eric Postpischil
Eric Postpischil

Reputation: 223702

The question appears to refer to this passage in What Every Computer Scientist Should Know About Floating-Point Arithmetic:

Consider the floating-point format with β = 10 and p = 3, which will be used throughout this section. If the result of a floating-point computation is 3.12 × 10-2, and the answer when computed to infinite precision is .0314, it is clear that this is in error by 2 units in the last place.

There are differences between this passage and that given in the question:

  • Goldberg describes 3.12 × 10-2 as the result of a computation, not as the “Closest FP no.” A computation may be a sequence of operations, and, although each operation individually may produce the floating-point number closest to the result of the corresponding real-number (“infinite precision”) operation given the same operands, the final result of the sequence is not necessarily the floating-point number closest to the result that would be obtained if all operations had been performed with real-number operations instead of floating-point operations.
  • Goldberg says the floating-point result has an error of 2 ULP relative to the real-number result, not that “ULP = 2.”

Given β = 10 and p = 3, the format uses significands of three decimal digits. The ULP, Unit of Least Precision, is simply the position value of the least significant digit. So, for the number .0312, the ULP is .0001. This passage in Goldberg observes that the difference between .0314 and .0312 is 2 ULP.

Upvotes: 4

Related Questions