JuliaIO / Formatting.jl

Deprecated. See README. (A Julia package to provide Python-like formatting support)
Other
130 stars 23 forks source link

Wrong for large numbers #65

Closed yakir12 closed 6 years ago

yakir12 commented 6 years ago

If this has an explanation I guess it should throw an error:

julia> s = format(111222333444555666, commas=true, precision = 2 , stripzeros = true )
"111,222,333,444,555,666"

julia> s = format(111222333444555666.01, commas=true, precision = 2 , stripzeros = true )
"111,222,333,444,555,664" # <= shouldn't this be "111,222,333,444,555,666.01"?
yuyichao commented 6 years ago

I don't think that's possible.

julia> typeof(111222333444555666.01)
Float64
yakir12 commented 6 years ago

Not sure what you mean. Is there a valid reason for that behavior? If so, maybe there should be some error or warning message?

yuyichao commented 6 years ago

The number you entered IS actually 111222333444555664 so no it's impossible to give an error or warning.

julia> eps(111222333444555666.01)
16.0
yakir12 commented 6 years ago

Lo and behold:

julia> 111222333444555666.01 == 111222333444555664
true

Ok, thank you.