Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!usc!ucsd!pacbell.com!pacbell!att!cbnewsc!sesv From: sesv@cbnewsc.att.com (steven.e.sommars) Newsgroups: comp.lang.c Subject: Re: more than you wanted hear about pow(3M) Summary: definition of ulp Keywords: pow accuracy Message-ID: <1990Aug13.140538.16171@cbnewsc.att.com> Date: 13 Aug 90 14:05:38 GMT References: <1990Aug12.045525.25626@cbnewsc.att.com> <24645@boulder.Colorado.EDU> Organization: AT&T Bell Laboratories Lines: 48 In article <24645@boulder.Colorado.EDU>, skwu@boulder.Colorado.EDU (WU SHI-KUEI) writes: > For us ignorami, what does an error of "190 ulps" mean? Thank you. An ulp is a Unit in the Last Place, roughly the amount a floating point number changes if the least significant bit is flipped. For IEEE double precision, this can be computed by logb(x)-52 ulp(x) = 2 where logb(x), an IEEE754 recommended function, is the unbiased exponent of x. For normalized numbers, an IEEE dp ulp is in the range: -52 -53 2 * x >= ulp(x) >= 2 * x [Attn. nitpickers: I have intentionally omitted details of denormalized numbers, ulp(powers of the radix), etc.] If we have an approximation, F(y), to a function whose true value at y is f(y), then error in ulps = (f(y) - F(y)) ------------- ulp(f(y)) [The choice in sign of error, (F-f) versus (f-F), is somewhat arbitrary.] An ulp is a measure of relative error, not absolute. A single precision function with maximum error of 1 ulp is not more accurate than a double precision function with maximum error of 3 ulps. Ulps are not hard to use. Let's say that the *true* result, T, of a computation is about 3.3, or when expressed in IEEE dp hex, T = 400AA3D70A3D70A4 [4E2...] The extra hex digits in [] won't fit into a IEEE word. The ulp error depends on the approximation. approx error in ulps 400AA3D70A3D70A6 -1.B1E (-1.694) 400AA3D70A3D70A5 -0.B1E (-0.694) 400AA3D70A3D70A4 0.4E2 ( 0.305) 400AA3D70A3D70A3 1.4E2 ( 1.305) The best we can hope for in computing transcendentals is a maximum error of 0.5 ulps (in round-to-nearest mode). The value 400AA3D70A3D70A4 is the best approximation to T, it has the smallest roundoff error. Steve Sommars sesv@cbnewsc.att.com