Skip to content

Commit

Permalink
Fix powers of negative integers
Browse files Browse the repository at this point in the history
  • Loading branch information
dpsanders committed May 22, 2019
1 parent a639347 commit 2ab8526
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/intervals/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,23 @@ function ^(x::Interval, n::Integer) # fast integer power
return Interval(zero(eltype(x)),
power_by_squaring(mag(x), n, RoundUp))

elseif x.lo > 0

a = power_by_squaring(x.lo, n, RoundDown)
b = power_by_squaring(x.hi, n, RoundUp)

return Interval(a, b)
#elseif x.lo > 0

else
a = power_by_squaring(x.hi, n, RoundDown)
b = power_by_squaring(x.lo, n, RoundUp)

a = power_by_squaring(x.lo, n, RoundDown)
b = power_by_squaring(x.hi, n, RoundUp)

return Interval(a, b)

end
#
# else # completely negative interval
# a = power_by_squaring(x.lo, n, RoundDown)
# b = power_by_squaring(x.hi, n, RoundUp)
#
# return Interval(a, b)
#end

end

Expand Down

0 comments on commit 2ab8526

Please sign in to comment.