Skip to content

Commit

Permalink
Treat lo==NaN as exact
Browse files Browse the repository at this point in the history
dpsanders committed Apr 28, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent fb1f3ad commit 13131f9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/FastRounding.jl
Original file line number Diff line number Diff line change
@@ -57,11 +57,11 @@ sqrt_round{T<:SysFloat}(a::T) = sqrt(a)
To perform arithmetic with directed rounding more rapidly
we use error-free transformations to control rounding
and quick, accurate float adjacency value calculation.
=#
=#

@inline function round_errorfree{T<:SysFloat}(hi::T, lo::T, ::RoundingMode{:Nearest})::T
return hi
end
end

@inline function round_errorfree{T<:SysFloat}(hi::T, lo::T, ::RoundingMode{:ToZero})::T
return signbit(hi) != signbit(lo) ? AdjacentFloats.next_nearerto_zero(hi) : hi
@@ -72,12 +72,12 @@ end
end

@inline function round_errorfree{T<:SysFloat}(hi::T, lo::T, ::RoundingMode{:Up})::T
return lo<=zero(T) ? hi : next_float(hi)
return (lo<=zero(T) || isnan(lo)) ? hi : next_float(hi)
end

@inline function round_errorfree{T<:SysFloat}(hi::T, lo::T, ::RoundingMode{:Down})::T
return lo>=zero(T) ? hi : prev_float(hi)
return (lo>=zero(T) || isnan(lo)) ? hi : prev_float(hi)
end


end # module

0 comments on commit 13131f9

Please sign in to comment.