Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix display of -0.0 to 0.0 #500

Merged
merged 7 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "IntervalArithmetic"
uuid = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
repo = "https://github.com/JuliaIntervals/IntervalArithmetic.jl.git"
version = "0.20.1"
version = "0.20.2"

[deps]
CRlibm = "96374032-68de-5a5b-8d9e-752f78720389"
Expand Down
5 changes: 3 additions & 2 deletions src/decorations/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,9 @@ function atan(yy::DecoratedInterval{T}, xx::DecoratedInterval{T}) where T
# Check cases when decoration is trv and decays (from com or dac)
if zero(T) ∈ y
zero(T) ∈ x && return DecoratedInterval(r, trv)
if x.hi < zero(T) && y.lo != y.hi && signbit(y.lo) && Int(d) > 2
return DecoratedInterval(r, decay(d))
if x.hi < zero(T)
y.lo < zero(T) && return DecoratedInterval(r, min(d, def))
return DecoratedInterval(r, min(d, dac))
end
end
DecoratedInterval(r, d)
Expand Down
2 changes: 1 addition & 1 deletion src/intervals/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ end


# Infimum and supremum of an interval
inf(a::Interval) = a.lo
inf(a::Interval) = ifelse(iszero(a.lo) && !signbit(a.lo), copysign(a.lo, -1), a.lo)
sup(a::Interval) = a.hi
lbenet marked this conversation as resolved.
Show resolved Hide resolved


Expand Down
6 changes: 5 additions & 1 deletion src/intervals/intervals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ struct Interval{T<:Real} <: AbstractInterval{T}

function Interval{T}(a::Real, b::Real) where T<:Real

a = _normalisezero(a)
b = _normalisezero(b)

if validity_check

if is_valid_interval(a, b)
new(a, b)
return new(a, b)

else
@warn "Invalid input, empty interval is returned"
Expand All @@ -36,6 +39,7 @@ struct Interval{T<:Real} <: AbstractInterval{T}
end
end

@inline _normalisezero(a::Real) = ifelse(iszero(a) && signbit(a), copysign(a, 1), a)


## Outer constructors
Expand Down