3 ms·
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?
by andi999 5y ago
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?
- aaaaaaaaaaab 5y agoBoth are exactly 0.0. Regarding signed zero, read this paper from Kahan: https://homes.cs.washington.edu/~ztatlock/599z-17sp/papers/branch-cuts-kahan-87.pdf https://homes.cs.washington.edu/~ztatlock/599z-17sp/papers/b...
- gvx 5y agoThe 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)
- MontyCarloHall 5y agoNo, those both yield +0. 0/(-x) would return -0, for all x > 0 Likewise, underflows on negative numbers would also return -0.
- thaumasiotes 5y ago> 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.
- 63 5y agoFrom some quick testing, -1.0 * 0.0 = -0.0 and the order doesn't matter.
- andi999 5y agoNice. So -1.0*(4 - 4)=-0.0 but -4 + 4=0.0