[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: support for bitwise comparison of floats

From: Paul Eggert
Subject: Re: support for bitwise comparison of floats
Date: Fri, 30 Mar 2007 00:31:00 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Bruno Haible <address@hidden> writes:

> In other words, the standard allows the function to be buggy...

The wording you quoted is talking about something else.  It is
referring to the behavior of the VAX floating point unit, where the
hardware representation that one thinks would represent -0.0 behaves
sort of like a NaN.  To avoid this problem, on a VAX copysign(0, -1)
returns +0.0, not the usual -0.0.  That is why the C and POSIX
standards are worded the way they are.  I expect the Linux manual just
picked it up from one of the standards.  (Does Linux run on a VAX?  :-)

This problem shouldn't affect us, as the code I proposed doesn't try
to compute -0.0.

I suggested copysign instead of the signbit macro because copysign has
been around a lot longer -- it was in the 1985 IEEE floating point
standard -- and is optimized better.  But if you want to play it safer
(and slower :-) you can use signbit.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]