A
artifact.one
Hello.
I want to be able to portably determine whether or not a given double
value is negative.
Under C99, I do:
if (signbit(d)) negative = 1;
Or, if the implementation doesn't provide signbit(), I do:
union real {
unsigned long long n;
double d;
};
if ((real.n >> 63) & 1) negative = 1;
However, what if I am to support an implementation that only provides
C89 (no long long, no signbit())?
Anybody got a reliable, portable method of handling this?
thanks,
mc
I want to be able to portably determine whether or not a given double
value is negative.
Under C99, I do:
if (signbit(d)) negative = 1;
Or, if the implementation doesn't provide signbit(), I do:
union real {
unsigned long long n;
double d;
};
if ((real.n >> 63) & 1) negative = 1;
However, what if I am to support an implementation that only provides
C89 (no long long, no signbit())?
Anybody got a reliable, portable method of handling this?
thanks,
mc