Re: [xml] XPath fix

From: "Bjorn Reese" <breese mail1 stofanet dk>
Presumably, also functions to set the sign explicitly (i.e., so I can
set a
value to -0)?

That is not necessary. You can assign -0.0 to a floating-point variable in

As an aside, as you seem to have a good understanding of floating point
numbers, could you confirm that both ceiling(-0.1) and round(-0.1)
return -0 and not +0?

That is correct. According to IEEE 754, the sign is preserved when
numbers, including zero.

In general, the sign rules that applies to normal numbers also applies to
zero. The only exceptions are the following two cases:

 x + x = -0 for x = -0
       = +0 for x = +0
       = +0 for x != 0

 sqrt(-0) = -0

Thanks for the explanation.

Apologies if this is a hideous cheat, but...
The code in trionan always appears to work off the idea that a double is 64
bits long.
As the sign is the 64th bit (the one on the left), wouldn't a simple way of
checking the sign just be to right shift the value, i.e.

int trio_get_sign(double a) {
    return a>>63;

I suspect there might be a more scientific way, but this seems to be the
simplest, and avoids doing three different things depending on the #defines
/ platform / implementation.


Do You Yahoo!?
Get your free address at

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