From ULP Wikipedia's page:
Another definition, suggested by John Harrison, is slightly different: ULP(x) is the distance between the two closest straddling floating-point numbers a and b (i.e., those with a ≤ x ≤ b and a ≠ b), assuming that the exponent range is not upper-bounded.
From IEEE 754 2008:
2.1.44 quantum: The quantum of a finite floating-point representation is the value of a unit in the last position of its significand. This is equal to the radix raised to the exponent q, which is used when the significand is regarded as an integer.
Question: What is the difference between ULP
(John Harrison's definition) and quantum
(from IEEE 754)?
Do I understand right that quantum of double x
can be computed as:
double ulp(double x)
{
int exp;
frexp( x, &exp );
return ldexp( 0.5, exp-52 );
}
double quantum(double x)
{
int exp;
return ulp(frexp( x, &exp ));
}