- Unit in the last place
In
computer science , Unit in the Last Place or Unit of Least Precision (ULP) is the gap between two very closefloating-point numbers. To be exact, ulp(x) is the gap between the two floating-point numbers closest to the value x.The amount of error in the evaluation of a floating-point operation is often expressed in ULP. An average error of 1 ULP is often seen as a tolerable error.
Example
If the ULP is less than or equal to 1, then adding 1 to a floating-point number will succeed. Otherwise, adding 1 will have no effect. This is demonstrated in the following Haskell code typed at an interactive prompt:
> until (x -> x = x+1) (+1) 0 :: Float 1.6777216e7 > it-1 1.6777215e7 > it+1 1.6777216e7
Here, we start with 32-bit
single-precision 0 and keep adding 1 until the operation is idempotent. The result is about 17 million.Another example, in Python, is (typed at an interactive prompt):
>>> x = 1.0 >>> while (x != x + 1.0): ... x = x * 10.0 ... >>> print x 1e+16
using
double-precision floating-point.Language support
Since Java 1.5, the Java standard library has included Javadoc:SE|java/lang|Math|ulp(double) and Javadoc:SE|java/lang|Math|ulp(float) functions.
References
* [ftp://ftp.inria.fr/INRIA/publication/publi-pdf/RR/RR-5504.pdf On the definition of ulp(x)] by Jean-Michel Muller, INRIA Technical Report 5504.
See also
*
IEEE 754
*Least significant bit
Wikimedia Foundation. 2010.