Skip to content

Commit

Permalink
Fix implicit conversion in +,-,*,/
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierHnt committed Sep 5, 2023
1 parent b34380d commit 1314740
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/intervals/arithmetic/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ end

function +(a::Interval{T}, b::T) where {T<:NumTypes}
isempty(a) && return a
isfinite(b) || return emptyinterval(T)
return @round(T, inf(a) + b, sup(a) + b)
end

Expand Down Expand Up @@ -96,6 +97,7 @@ end

function *(a::Interval{T}, b::T) where {T<:NumTypes}
(isempty(a) || isthinzero(a) || isone(b)) && return a
isfinite(b) || return emptyinterval(T)
if b 0
return @round(T, inf(a) * b, sup(a) * b)
else
Expand Down Expand Up @@ -173,6 +175,7 @@ end

function /(a::Interval{T}, b::T) where {T<:NumTypes}
isempty(a) && return a
isfinite(b) || return emptyinterval(T)
iszero(b) && return div_by_thin_zero(a)
if b 0
return @round(T, inf(a)/b, sup(a)/b)
Expand Down

0 comments on commit 1314740

Please sign in to comment.