Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix complex exponential for real overflow (#5521)

  • Loading branch information...
commit 6382a19a211846357f54817c07447f7a9be07cd9 1 parent 34fdd4f
@jiahao jiahao authored
Showing with 2 additions and 1 deletion.
  1. +2 −1  base/complex.jl
View
3  base/complex.jl
@@ -331,7 +331,8 @@ function exp(z::Complex)
if zr==-Inf && !isfinite(zi) return Complex(-zero(zr), copysign(zero(zi), zi)) end
if zr==Inf && !isfinite(zi) return Complex(-zr, oftype(zr, NaN)) end
if isnan(zr) return Complex(zr, zi==0 ? zi : zr) end
- er = zr==Inf ? zr : exp(zr)
+ er = exp(zr)
+ zi==0 && return Complex(er, zi)
wr = er*(isfinite(zi) ? cos(zi) : zi)
wi = er*(isfinite(zi) ? sin(zi) : zi)
Complex(wr, wi)
Please sign in to comment.
Something went wrong with that request. Please try again.