News for hackers. Stuff that matters.
Re:One does not simply calculate the absolute value by andi999 on Sunday August 22, 2021 @04:38PM (#28269376)
Does anybody know a good reference on the minus 0 thing? How do you end up with it? Is 4-4=+0.0 and -4 +4=-0.0? Or is it different?
Re:One does not simply calculate the absolute value by aaaaaaaaaaab on Sunday August 22, 2021 @04:42PM (#28269407)
Both are exactly 0.0.

Regarding signed zero, read this paper from Kahan: https://homes.cs.washington.edu/~ztatlock/599z-17sp/papers/b...

Re:One does not simply calculate the absolute value by gvx on Sunday August 22, 2021 @04:44PM (#28269427)
The easiest way to get a signed zero is with a unary minus operation. That is, the expression -x produces -0.0 when x is an unsigned zero (so 0.0)
Re:One does not simply calculate the absolute value by 63 on Sunday August 22, 2021 @04:49PM (#28269474)
From some quick testing, -1.0 * 0.0 = -0.0 and the order doesn't matter.
Re:One does not simply calculate the absolute value by andi999 on Wednesday August 25, 2021 @08:30AM (#28300800)
Nice. So -1.0*(4 - 4)=-0.0 but -4 + 4=0.0
Re:One does not simply calculate the absolute value by MontyCarloHall on Sunday August 22, 2021 @04:47PM (#28269460)
No, those both yield +0.

0/(-x) would return -0, for all x > 0

Likewise, underflows on negative numbers would also return -0.

Re:One does not simply calculate the absolute value by thaumasiotes on Sunday August 22, 2021 @05:44PM (#28269946)
> 0/(-x) would return -0, for all x > 0

I find this one a little weird, but it seems to be true.

The more normal way to get -0 would be to divide a positive number by negative infinity, or a negative number by positive infinity.