Skip to content

Commit 7c46049

Browse files
committed
Fix is_valid_interval
1 parent d44f607 commit 7c46049

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/intervals/flavor.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,8 @@ contains_infinity(x::BareInterval) = contains_infinity(default_flavor(), x)
9191
For the given flavor `F`, test whether ``[a, b]`` is a valid interval.
9292
"""
9393
is_valid_interval(::Flavor{:set_based}, a::Real, b::Real) = b - a 0
94+
# to prevent issues with division by zero, e.g. `is_valid_interval(1//0, 1//0)`
95+
is_valid_interval(::Flavor{:set_based}, a::Rational, b::Rational) =
96+
!((a > b) | (a == typemax(typeof(a))) | (b == typemin(typeof(b))))
9497

9598
is_valid_interval(a::Real, b::Real) = is_valid_interval(default_flavor(), a, b)

0 commit comments

Comments
 (0)