Skip to content

Commit c6270bf

Browse files
committed
Fix BigFloat rounding for irrationals :ℯ and :φ
1 parent 2a2fa98 commit c6270bf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/intervals/construction.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ interval(::Type{T}, a::Real, b::Complex) where {T} = complex(interval(T, a, real
116116
interval(a::Real, b::Complex) = complex(interval(a, real(b)), interval(a, imag(b)))
117117

118118
# Irrational
119+
# By-pass the absence of `BigFloat(..., ROUNDING_MODE)` (cf. base/irrationals.jl)
120+
# for some irrationals defined in MathConstants (cf. base/mathconstants.jl)
121+
for sym (:ℯ, )
122+
Interval{BigFloat}(a::Irrational{sym}, b::Irrational{sym}) =
123+
Interval{BigFloat}(BigFloat(Float64(a, RoundDown), RoundDown), BigFloat(Float64(b, RoundUp), RoundUp))
124+
Interval{BigFloat}(a::Irrational{sym}, b) =
125+
Interval{BigFloat}(BigFloat(Float64(a, RoundDown), RoundDown), BigFloat(b, RoundUp))
126+
Interval{BigFloat}(a, b::Irrational{sym}) =
127+
Interval{BigFloat}(BigFloat(a, RoundDown), BigFloat(Float64(b, RoundUp), RoundUp))
128+
end
119129
# The following function is put here because generated functions must be defined
120130
# after all the methods they use
121131
@generated function interval(::Type{T}, a::Irrational) where {T}

0 commit comments

Comments
 (0)