On Fri, Oct 12, 2012 at 8:42 PM, Tim Peters
In part it's to preserve various identities, such as that sqrt(conjugate(z)) is the same as conjugate(sqrt(z)). When z is +0, that becomes
sqrt(conjugate(+0)) same_as conjugate(sqrt(+0))
which is
sqrt(-0) same_as conjugate(+0)
which is
sqrt(-0) same as -0
Conviced?
Not really. :-) In fact, it's exactly that paper that made me think sqrt(-0.0) -> -0.0 is suspect. The way I read it, the argument from the paper implies that cmath.sqrt(complex(0.0, -0.0)) should be complex(0.0, -0.0), which I have no problem with---it makes things nice and neat: quadrants 1 and 2 in the complex plane map to quadrant 1, and quadrants 3 and 4 to quadrant 4, with the signs of the zeros making it clear what 'quadrant' means in all (non-nan) cases. But I don't see how to get from there to math.sqrt(-0.0) being -0.0. It's exactly the mismatch between the real and complex math that makes no sense to me: math.sqrt(-0.0) should resemble cmath.sqrt(complex(-0.0, +/-0.0)). But the latter, quite reasonably, is complex(0.0, +/-0.0) (at least according to both Kahan and C99 Annex G), while the former is specified to be -0.0 in IEEE 754. -- Mark