Skip to content

Commit

Permalink
fix bug in complex sqrt with -0.0 imaginary part
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Apr 12, 2013
1 parent 0280dbd commit d3c66e9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function sqrt(z::Complex)
if rz >= 0
return complex(r, iz/r/2)
end
return complex(abs(iz)/r/2, iz >= 0 ? r : -r)
return complex(abs(iz)/r/2, copysign(r,iz))
end

cis(theta::Real) = complex(cos(theta),sin(theta))
Expand Down

0 comments on commit d3c66e9

Please sign in to comment.