diff --git a/src/intervals/functions.jl b/src/intervals/functions.jl index be3de79c2..cc9d6f2b1 100644 --- a/src/intervals/functions.jl +++ b/src/intervals/functions.jl @@ -378,7 +378,7 @@ end Calculate `x mod y` where `x` is an interval and `y` is a positive divisor. """ function mod(x::Interval, y::Real) - @assert y > 0 "modulo is currently implemented only for a positive divisor." + @assert y > zero(y) "modulo is currently implemented only for a positive divisor." division = x / y fl = floor(division) fl.lo < fl.hi ? Interval(zero(y), y) : y * (division - fl) diff --git a/test/interval_tests/numeric.jl b/test/interval_tests/numeric.jl index d23b679e1..3d88a91a0 100644 --- a/test/interval_tests/numeric.jl +++ b/test/interval_tests/numeric.jl @@ -458,4 +458,6 @@ end @test mod(x, 2) == mod(x, 2.0) == 0..2 @test mod(x, 2.5) == 0..2.5 @test mod(x, 0.5) == 0..0.5 + + @test_throws AssertionError mod(x, -1) end