diff --git a/base/ryu/utils.jl b/base/ryu/utils.jl index b9b4bac675cb45..656b28a4021788 100644 --- a/base/ryu/utils.jl +++ b/base/ryu/utils.jl @@ -372,23 +372,21 @@ end const POW10_OFFSET_2, MIN_BLOCK_2, POW10_SPLIT_2 = generateinversetables() -bitlength(this) = Base.GMP.MPZ.sizeinbase(this, 2) - @inline function pow5invsplit(::Type{Float64}, i) pow = big(5)^i - inv = div(big(1) << (bitlength(pow) - 1 + pow5_inv_bitcount(Float64)), pow) + 1 + inv = div(big(1) << (ndigits(pow, base=2) - 1 + pow5_inv_bitcount(Float64)), pow) + 1 return (UInt64(inv & ((big(1) << 64) - 1)), UInt64(inv >> 64)) end @inline function pow5invsplit(::Type{Float32}, i) pow = big(5)^i - inv = div(big(1) << (bitlength(pow) - 1 + pow5_inv_bitcount(Float32)), pow) + 1 + inv = div(big(1) << (ndigits(pow, base=2) - 1 + pow5_inv_bitcount(Float32)), pow) + 1 return UInt64(inv) end @inline function pow5invsplit(::Type{Float16}, i) pow = big(5)^i - inv = div(big(1) << (bitlength(pow) - 1 + pow5_inv_bitcount(Float16)), pow) + 1 + inv = div(big(1) << (ndigits(pow, base=2) - 1 + pow5_inv_bitcount(Float16)), pow) + 1 return UInt32(inv) end