Skip to content

Commit 2ef0305

Browse files
Merge pull request #226 from JuliaMath/fast-<=
Fast <=
2 parents bd164ee + a17f520 commit 2ef0305

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ keywords = ["math", "floating-point", "doubledouble", "extended-precision", "acc
44
license = "MIT"
55
desc = "extended precision floating point types using value pairs"
66
repo = "https://github.com/JuliaMath/DoubleFloats.jl.git"
7-
version = "1.5.2"
7+
version = "1.5.3"
88

99
[deps]
1010
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/type/compare.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ end
1212
return (LO(x) !== LO(y)) || (HI(x) !== HI(y) || posnegzeros(HI(x),HI(y)))
1313
end
1414
@inline function (<)(x::DoubleFloat{T}, y::DoubleFloat{T}) where {T<:IEEEFloat}
15-
return (HI(x) < HI(y)) || (HI(x) == HI(y) && LO(x) < LO(y))
15+
return (HI(x) < HI(y)) || (HI(x) === HI(y) && LO(x) < LO(y))
1616
end
1717
@inline function (<=)(x::DoubleFloat{T}, y::DoubleFloat{T}) where {T<:IEEEFloat}
18-
return (HI(x) < HI(y)) || (HI(x) == HI(y) && LO(x) <= LO(y))
18+
return (HI(x) < HI(y)) || (HI(x) === HI(y) && LO(x) <= LO(y)) || posnegzeros(HI(x), HI(y))
1919
end
2020

2121
@inline function isequal(x::DoubleFloat{T}, y::DoubleFloat{T}) where {T<:IEEEFloat}

test/compare.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ f3 = 3.0
88
d3 = Double64(3.0)
99
b3 = BigFloat(3)
1010
r3 = 3//1
11+
p0 = Double64(0.0)
12+
n0 = Double64(-0.0)
1113

1214
small = Double64(0.25*eps(1.0))
1315
gt1 = one(Double64) + small
@@ -127,3 +129,18 @@ end
127129
@test lt1 < 1.0
128130
@test !(lt1 > 1.0)
129131
end
132+
133+
@testset "compare zeros" begin
134+
@test !(p0 === n0)
135+
@test p0 == n0
136+
137+
@test p0 <= n0
138+
@test n0 <= p0
139+
@test !(p0 < n0)
140+
@test !(n0 < p0)
141+
142+
@test p0 >= n0
143+
@test n0 >= p0
144+
@test !(p0 > n0)
145+
@test !(n0 > p0)
146+
end

0 commit comments

Comments
 (0)