On Fri, Oct 24, 2008 at 09:37:41AM +0200, Abdelrazak Younes wrote:
> Nope, I would just test the difference to be less than 'epsilon' 
> instead. And 'epsilon = 1e-307' for a double IIRC.

You don't recall correctly. That is the smallest number representable
with a double. The precision epsilon is the smallest number such that
1 + epsilon != 1. The attached C program will tell you what epsilon is.

> And FYI a double is a 
> double is a 64bit on any platform ;-)

Yep.

-- 
Enrico
#include <stdio.h>

int main(void)
{
    double u;
    double eps;
    double unit = 1.0;
    do {
        eps = unit;
        unit = 0.5 * unit;
        u = 1.0 - unit;
    } while (u < 1.0);
    printf("eps = %9.2e\n", 2.0 * eps);
    return 0;
}

Reply via email to