
At 6:57 PM +0000 11/17/05, Paul A Bristow wrote:
fpclassify
#define fpclassify(x) <int rvalue> [added with C99, int functions in C++]
[...]
The positive and negative infinties and zeros really are different in representation in MS world at least, but I fear you may just have to ignore that.
http://www2.open-std.org/JTC1/SC22/WG14/www/C99RationaleV5.10.pdf
does not provide any rationale for the lack of sign on infinity and zero.
Getting -zero is unlikely to be a problem, but getting +infinity instead of -infinity could be most confusing - as different as you can get ;-)
I suspect C99 put it in the 'too difficult' box?
To test for negative infinity and negative zero, use fpclassify(x) and signbit(x). To build a negative infinity, I think copysign of a positive infinity and a negative sign supplier ought to work, and likely will work in practice; C99 specifies that it works for NaNs, but is actually silent about what it does for infinities (sigh!). copysign can also be used to obtain a negative zero, for those platforms which actually support negative zero.