Skip to content

Commit d473f78

Browse files
committed
Fix ^
1 parent 358848b commit d473f78

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/intervals/arithmetic/power.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ end
1919
# overwrite new behaviour for small integer powers from
2020
# https://github.com/JuliaLang/julia/pull/24240:
2121

22-
Base.literal_pow(::typeof(^), x::Interval{T}, ::Val{p}) where {T,p} = x^p
22+
Base.literal_pow(::typeof(^), x::Interval{T}, ::Val{p}) where {T<:NumTypes,p} = x^p
2323

2424
# CRlibm does not contain a correctly-rounded ^ function for Float64
2525
# Use the BigFloat version from MPFR instead, which is correctly-rounded.
@@ -118,9 +118,9 @@ function ^(a::F, x::BigFloat) where {F<:Interval{BigFloat}}
118118
return hull(lo, hi)
119119
end
120120

121-
function ^(a::Interval{Rational{T}}, x::AbstractFloat) where {T<:Integer}
122-
a = Interval{Float64}(inf(a).num/inf(a).den, sup(a).num/sup(a).den)
123-
return a^x
121+
function ^(a::F, x::AbstractFloat) where {F<:Interval{<:Rational}}
122+
a = float(F)(inf(a).num/inf(a).den, sup(a).num/sup(a).den)
123+
return F(a^x)
124124
end
125125

126126
# Rational power

src/intervals/construction.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ end
229229
const precision_lock = ReentrantLock()
230230

231231
"""
232-
bigequiv(x::Interval{Float64})
232+
bigequiv(x::Interval)
233233
234-
Create an equivalent `BigFloat` interval to a given `AbstractFloat` interval.
234+
Create an equivalent `BigFloat` interval to a given interval.
235235
"""
236-
function bigequiv(a::Interval{T}) where {T<:AbstractFloat}
236+
function bigequiv(a::Interval{T}) where {T<:NumTypes}
237237
lock(precision_lock) do
238-
setprecision(precision(T)) do # precision of T
238+
setprecision(precision(float(T))) do # precision of T
239239
return Interval{BigFloat}(a)
240240
end
241241
end

0 commit comments

Comments
 (0)