Skip to content

Commit 8519f38

Browse files
Update prearith.jl
1 parent 4999a18 commit 8519f38

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/math/prearith/prearith.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,21 @@ ulp(::Type{D}) where {T<:AbstractFloat, D<:DoubleFloat{T}} = D(posulp(poslulp(on
100100

101101

102102
function Base.Math.nextfloat(x::DoubleFloat{T}) where {T<:IEEEFloat}
103-
!isfinite(x) && return(x)
104-
if !iszero(LO(x))
103+
if !isfinite(x)
104+
isnan(x) && return x
105+
signbit(x) ? floatmin(DoubleFloat{T}) : x
106+
elseif !iszero(LO(x))
105107
DoubleFloat{T}(HI(x)) + nextfloat(LO(x))
106108
else
107109
DoubleFloat{T}(HI(x), ulp(ulp(HI(x))))
108110
end
109111
end
110112

111113
function Base.Math.prevfloat(x::DoubleFloat{T}) where {T<:IEEEFloat}
112-
!isfinite(x) && return(x)
113-
if !iszero(LO(x))
114+
if !isfinite(x)
115+
isnan(x) && return x
116+
signbit(x) ? x : floatmax(DoubleFloat{T})
117+
elseif !iszero(LO(x))
114118
DoubleFloat{T}(HI(x)) + prevfloat(LO(x))
115119
else
116120
DoubleFloat{T}(HI(x), -ulp(ulp(HI(x))))

0 commit comments

Comments
 (0)