Skip to content

Commit 75f53c0

Browse files
lbenetlucaferranti
andauthored
Fix display of -0.0 to 0.0 (#500)
* Fix display of -0.0 to 0.0 * Add _normalisezero (instead of _signofzero) and fix display of inf * Reposition use of _normalisezero * fix atan2 for decorated intervals * small update * Clean-up _normalisezero * Bump patch version Co-authored-by: lucaferranti <[email protected]>
1 parent af22f4a commit 75f53c0

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "IntervalArithmetic"
22
uuid = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
33
repo = "https://github.com/JuliaIntervals/IntervalArithmetic.jl.git"
4-
version = "0.20.1"
4+
version = "0.20.2"
55

66
[deps]
77
CRlibm = "96374032-68de-5a5b-8d9e-752f78720389"

src/decorations/functions.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,9 @@ function atan(yy::DecoratedInterval{T}, xx::DecoratedInterval{T}) where T
314314
# Check cases when decoration is trv and decays (from com or dac)
315315
if zero(T) y
316316
zero(T) x && return DecoratedInterval(r, trv)
317-
if x.hi < zero(T) && y.lo != y.hi && signbit(y.lo) && Int(d) > 2
318-
return DecoratedInterval(r, decay(d))
317+
if x.hi < zero(T)
318+
y.lo < zero(T) && return DecoratedInterval(r, min(d, def))
319+
return DecoratedInterval(r, min(d, dac))
319320
end
320321
end
321322
DecoratedInterval(r, d)

src/intervals/arithmetic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ end
302302

303303

304304
# Infimum and supremum of an interval
305-
inf(a::Interval) = a.lo
305+
inf(a::Interval) = ifelse(iszero(a.lo) && !signbit(a.lo), copysign(a.lo, -1), a.lo)
306306
sup(a::Interval) = a.hi
307307

308308

src/intervals/intervals.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ struct Interval{T<:Real} <: AbstractInterval{T}
1919

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

22+
a = _normalisezero(a)
23+
b = _normalisezero(b)
24+
2225
if validity_check
2326

2427
if is_valid_interval(a, b)
25-
new(a, b)
28+
return new(a, b)
2629

2730
else
2831
@warn "Invalid input, empty interval is returned"
@@ -36,6 +39,7 @@ struct Interval{T<:Real} <: AbstractInterval{T}
3639
end
3740
end
3841

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

4044

4145
## Outer constructors

0 commit comments

Comments
 (0)