Skip to content

Commit

Permalink
speed up Ryu.pow5 (#46764)
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardssmith authored Oct 6, 2022
1 parent a3c7d7f commit ce04b75
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions base/ryu/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,7 @@ lengthforindex(idx) = div(((Int64(16 * idx) * 1292913986) >> 32) + 1 + 16 + 8, 9
Return `true` if `5^p` is a divisor of `x`.
"""
@inline function pow5(x, p)
count = 0
while true
q = div(x, 5)
r = x - 5 * q
r != 0 && return count >= p
x = q
count += 1
end
x % (5^p) == 0
end

"""
Expand Down

0 comments on commit ce04b75

Please sign in to comment.