Skip to content

Commit

Permalink
Fix #9618
Browse files Browse the repository at this point in the history
If y in (x::BigInt)^y exceeds typemax of Uint and |x|>1, the result will
overflow. In this case, return OverflowError. Otherwise retain the
current behavior of returning a DomainError.
  • Loading branch information
jiahao committed Jan 6, 2015
1 parent 930cfe6 commit 2895ced
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/gmp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ function bigint_pow(x::BigInt, y::Integer)
if y<0; throw(DomainError()); end
if x== 1; return x; end
if x==-1; return isodd(y) ? x : -x; end
if y>typemax(UInt); throw(DomainError()); end
if y>typemax(UInt); throw(abs(x)>1 ? OverflowError() : DomainError()); end
return x^uint(y)
end

Expand Down

0 comments on commit 2895ced

Please sign in to comment.