cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ] #include <mathcw.h> extern float ulpmhf (double x); extern double ulpmh (long double x); extern long double ulpmhl (long_long_double x); extern __float80 ulpmhw (long_long_double x); extern __float128 ulpmhq (long_long_double x); extern long_long_double ulpmhll (long_long_double x); extern decimal_float ulpmhdf (decimal_double x); extern decimal_double ulpmhd (decimal_long_double x); extern decimal_long_double ulpmhdl (decimal_long_long_double x); extern decimal_long_long_double ulpmhdll (decimal_long_long_double x);
NB: Functions with prototypes containing underscores in type names may be available only with certain extended compilers.
If x is a real number that lies between two finite consecutive floating-point numbers a and b, without being equal to one of them, then ulpmh(x) = |b - a|, otherwise ulpmh(x) is the distance between the two finite floating-point numbers nearest x. Moreover, ulpmh(NaN) is a NaN.
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.
This ulp function has this useful property:
For a binary base only, if X is a machine number that approximates an infinite-precision real number x such that |X - x| < (1/2)ulpmh(x), then X is the machine number nearest x.The converse is looser:
For any integer base, if X is the machine number nearest x, then |X - x| <= (1/2)ulpmh(x).
The ulp function also has the properties that ulpmh(x) > 0 and ulpmh(-x) = ulpmh(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 machine number in the precision of the function, then this function is equivalent to the Kahan ulp function, ulpk(3CW). However, for x values of higher precision, the two ulp functions differ in their handling of arguments just above an exponent boundary: the Kahan ulp is the gap below that boundary, while the Muller--Harrison ulp is the gap above that boundary.
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.