On Mon, 2 Aug 2010, Bo Lindbergh wrote: > Nicholas Clark wrote: > > What I can't work out is whether there is any shortcut way in ANSI C to find > > out whether a value is -0, distinct from 0, short of *printf(). > > As long as the compiler is sufficiently C99-like: > > fpclassify(value)==FP_ZERO && signbit(value) Yes, both copysign() and signbit() are widely available. The challenge arises in that perl tries to rely only on C89-like behavior, since not all compilers support the C99 standard. To help provide appropriate warnings to developers who use gcc, we often add -ansi to gcc's flags, which effectively hides things like signbit(). In ANSI C, if signbit() isn't available, the only other thing I can think of doing is to assume IEEE-754 and explicitly check the correct bit some way or another. -- Andrew Dougherty doughera@lafayette.eduThread Previous | Thread Next