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 2 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 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
7 changes: 5 additions & 2 deletions src/intervals/intervals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ struct Interval{T<:Real} <: AbstractInterval{T}
function Interval{T}(a::Real, b::Real) where T<:Real

if validity_check

a = _normalisezero(a)
lbenet marked this conversation as resolved.
Show resolved Hide resolved
b = _normalisezero(b)
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 +37,8 @@ struct Interval{T<:Real} <: AbstractInterval{T}
end
end

@inline _normalisezero(a::Real) = ifelse(iszero(a) && signbit(a), copysign(a, 1), a)
@inline _normalisezero(a::Integer) = float(a)
lbenet marked this conversation as resolved.
Show resolved Hide resolved


## Outer constructors
Expand Down