Skip to content

Commit

Permalink
Fix #14698 while we're here deep in the float printing code anyway
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Aug 7, 2019
1 parent a5046bd commit 303bc54
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
9 changes: 6 additions & 3 deletions base/ryu/exp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@
while i < 200
j = 120 + (-e2 - 16 * idx)
p = POW10_OFFSET_2[idx + 1] + i - MIN_BLOCK_2[idx + 1]
# @show i, p, pos
#=@inbounds=# mula, mulb, mulc = POW10_SPLIT_2[p + 1]
digits = p >= POW10_OFFSET_2[idx + 2] ? 0 : mulshiftmod1e9(m2 << 8, mula, mulb, mulc, j + 8)
if p >= POW10_OFFSET_2[idx + 2]
digits = 0
else
#=@inbounds=# mula, mulb, mulc = POW10_SPLIT_2[p + 1]
digits = mulshiftmod1e9(m2 << 8, mula, mulb, mulc, j + 8)
end
if printedDigits != 0
if printedDigits + 9 > precision
availableDigits = 9
Expand Down
16 changes: 16 additions & 0 deletions test/ryu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,22 @@ end
@test Ryu.writeexp(1e+83, 1) == "1.0e+83"
end

# 14698
@test Ryu.writeexp(floatmin(), 1000) ==
"2.2250738585072013830902327173324040642192159804623318305533274168872044348139181958" *
"54283159012511020564067339731035811005152434161553460108856012385377718821130777993" *
"53200233047961014744258363607192156504694250373420837525080665061665815894872049117" *
"99685916396485006359087701183048747997808877537499494515804516050509153998565824708" *
"18645113537935804992115981085766051992433352114352390148795699609591288891602992641" *
"51106346631339366347758651302937176204732563178148566435087212282863764204484681140" *
"76139114770628016898532441100241614474216185671661505401542850847167529019031613227" *
"78896729707373123334086988983175067838846926092773977972858659654941091369095406136" *
"46756870239867831529068098461721092462539672851562500000000000000000000000000000000" *
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000" *
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000" *
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000" *
"00000e-308"

end # exp

end # Ryu

0 comments on commit 303bc54

Please sign in to comment.