Boost logo

Boost :

From: Johan Råde (rade_at_[hidden])
Date: 2008-02-25 16:08:03


>>> I am missing the point of the changesign function. What is its
>>> rationale? The documentation talks about copysign(x, signbit(x) ? 1 :
>>> -1) but not about -x. So I am a bit lost.

>> Is -x guaranteed to change the sign of zero and NaN?
>> If it is, then I agree that the function is superfluous.

> Back to the topic at hand, I don't know of any architecture/compiler
> where negating a number does not flip the sign bit of the number, so -x
> works both for zero and NaN.

I just found out that for the ia32 architecture,
unary minus flips the signbit of NaN if you use the x87 units,
but not if you use the SSE units.
So the changesign function is useful.

I should point this out in the docs.

--Johan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk