On Fri, Feb 11, 2011 at 11:16:55PM +0100, Stefan D?singer wrote:
> .... Its just that this function goes to great lengths to 
> make sure it doesn't rely on the actual encoding that it is annoying that we 
> have to give it up for detecting the sign of zeroes.

In that case why not?

int
is_neq_z(double x)
{
    union {
        char i[sizeof (double)];
        double d;
    } ux, u0;
    int i;

    if (x != 0.0)
        return 0;
    u0.d = 0.0;
    ux.d = x;
    for (i = 0; i < sizeof (double); i++) {
        if (ux.i[i] != u0.i[i])
            return 1;
    }
    return 0;
}

Which works provided that there are only 2 encoding patterns for zero.

        David

-- 
David Laight: da...@l8s.co.uk


Reply via email to