This repository was archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
printfmt("1:.4e, 40000.0) prints 3.10000e+04 #71
Comments
What version of Julia and Formatting are you using? With Julia 1.0.0 and Formatting 0.3.4 I get:
|
What do you get for the following?
I don't have access to a Windows 7 machine but it seems odd that this would be Windows specific. |
|
A similar issue was reported on discourse: julia> using Formatting
julia> format("{1:.4e}", 3.0e-8)
"2.10000e-08" This is with Formatting v0.4.2 and Julia 1.6.1 on macOS. (The |
In general, I get lots of erroneous results for formatting numbers that are approximately integers times negative powers of ten: julia> for i = 1:1000
x = (rand(Bool) ? +1 : -1) * rand(1:9) * exp10(rand(-10:10))
s = format("{1:.4e}", x)
if !isapprox(x, parse(Float64, s), rtol=1e-3)
@show x, s
end
end
(x, s) = (0.0006000000000000001, "5.10000e-04")
(x, s) = (-7.000000000000001e-5, "-6.10000e-05")
(x, s) = (0.0006000000000000001, "5.10000e-04")
(x, s) = (-0.00030000000000000003, "-2.10000e-04")
(x, s) = (0.0006000000000000001, "5.10000e-04")
(x, s) = (6.000000000000001e-8, "5.10000e-08")
(x, s) = (3.0000000000000004e-8, "2.10000e-08")
(x, s) = (-6.000000000000001e-8, "-5.10000e-08")
(x, s) = (7.000000000000001e-5, "6.10000e-05")
(x, s) = (-0.0006000000000000001, "-5.10000e-04")
(x, s) = (-3.0000000000000004e-8, "-2.10000e-08")
(x, s) = (-0.00030000000000000003, "-2.10000e-04")
(x, s) = (-3.0000000000000004e-8, "-2.10000e-08")
(x, s) = (6.000000000000001e-8, "5.10000e-08")
(x, s) = (-0.0006000000000000001, "-5.10000e-04")
(x, s) = (7.000000000000001e-5, "6.10000e-05")
(x, s) = (3.0000000000000004e-8, "2.10000e-08")
(x, s) = (-3.0000000000000004e-8, "-2.10000e-08")
(x, s) = (-3.0000000000000004e-8, "-2.10000e-08")
(x, s) = (3.0000000000000004e-8, "2.10000e-08")
(x, s) = (-3.0000000000000004e-8, "-2.10000e-08")
(x, s) = (-0.0006000000000000001, "-5.10000e-04")
(x, s) = (0.00030000000000000003, "2.10000e-04")
(x, s) = (0.0006000000000000001, "5.10000e-04") |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
printfmt("1:.4e, 40000.0)
should print4.0000e+04
, but it prints3.10000e+04
.The text was updated successfully, but these errors were encountered: