Skip to content

Commit

Permalink
Fix mixed sign case
Browse files Browse the repository at this point in the history
As it turns out, our `mod` is not the same as C's `fmod`; that one is
`rem`.
  • Loading branch information
ararslan committed Sep 25, 2021
1 parent 0234844 commit 9d4df8f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ function rem(x::Float64, p::Float64, ::RoundingMode{:Nearest})
return NaN
end
if hp <= 0x7fdfffff
x = mod(x, p + p) # now x < 2p
x = rem(x, p + p) # now x < 2p
end
((hx - hp) | (lx - lp)) == 0 && return 0.0
x = abs(x)
Expand Down Expand Up @@ -932,7 +932,7 @@ function rem(x::Float32, p::Float32, ::RoundingMode{:Nearest})
return NaN32
end
if hp <= 0x7effffff
x = mod(x, p + p) # now x < 2p
x = rem(x, p + p) # now x < 2p
end
hx - hp == 0 && return 0.0f0
x = abs(x)
Expand Down

0 comments on commit 9d4df8f

Please sign in to comment.