cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ] #include <mathcw.h> extern float ulpkf (double x); extern double ulpk (long double x); extern long double ulpkl (long_long_double x); extern __float80 ulpkw (long_long_double x); extern __float128 ulpkq (long_long_double x); extern long_long_double ulpkll (long_long_double x); extern decimal_float ulpkdf (decimal_double x); extern decimal_double ulpkd (decimal_long_double x); extern decimal_long_double ulpkdl (decimal_long_long_double x); extern decimal_long_long_double ulpkdll (decimal_long_long_double x);
NB: Functions with prototypes containing underscores in type names may be available only with certain extended compilers.
ulpk(x) is the gap between the two finite floating-point numbers nearest x, even if x is not contained in that interval.
Notice that the argument has higher precision than the function result, except at the highest available precisions. The computed ulp measure is that of the function precision.
For any integer base, this ulp function has this useful property:
If X is a machine number that approximates an infinite-precision real number x such that |X - x| < (1/2)ulpk(x), then X is the machine number nearest x.The converse is more restrictive:
In binary arithmetic only, if X is the machine number nearest x, then |X - x| <= (1/2)ulpk(x).
The ulp function also has the properties that ulpk(x) > 0 and ulpk(-x) = ulpk(x) when the argument is not a NaN.
If subnormals are supported, and |x| is equal to or smaller than the minimum normal number in the type of the function, then the function returns the smallest subnormal number.
If subnormals are not supported, then for tiny arguments, the function returns the smallest normal number.
If x is larger than the maximum representable floating-point value in the type of the function, the return value is the gap between that number and the machine number just below it.
If x is a NaN, return that NaN. Otherwise, the return value is always finite (even if the argument is Infinity), nonzero, and equal to an exact power of the floating-point base.