Computation of the machine epsilon (macheps
) on x86
using approximating algorithm like:
value = 1.0;
epsilon = 1.0;
sum = value + epsilon;
while (value != sum)
{
epsilon = epsilon / 2.0;
sum = value + epsilon;
}
The approach used here is:
- Computations are done by assembly functions
- Constants
1.0
and2.0
are computed using corresponding FPU instructions - Comparison of the
value
andsum
is done raw withmemcmp()
function - Additionally the loops are counted and printed out with the
epsilon
Machine epsilon (fp32):
Loop counter: 24
epsilon: 5.96046e-08
Machine epsilon (fp64):
Loop counter: 53
epsilon: 1.11022e-16
Machine epsilon (fp80):
Loop counter: 64
epsilon: 5.42101e-20
The assembly functions have been generated using my cppasm generator.
See also macheps-128.