-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential conversion issues with numbers #15
Comments
We ran into this issue recently, and I want to report another two examples of the above: julia> Float64(LazyJSON.parse("1.7272"))
1.7271999999999998
julia> Float64(LazyJSON.parse("1.727"))
1.7269999999999999 From what I can tell from reading the spec that's linked (https://tools.ietf.org/html/rfc7159#section-6), json is supposed to be able to represent any Float64 value losslessly from julia? Is that how I should read this?:
What would you think about changing the custom Lines 136 to 150 in 53c63f0
be implemented via calls to Something like this?: for T in (Int8, Int16, #= ..., =# Float64,)
@eval Base.$T(n::JSON.Number)::$T = Base.parse($T, @view n.s[n.i:end])
end This way we would ensure that we keep the parse equivalent to how Julia would parse it, and simplify the implementation? After a bit more reading, I see now that you want a custom Line 172 in 53c63f0
Line 212 in 53c63f0
But I think you could keep the current implementation of Anyway, I would appreciate your thoughts on this! Thanks very much. |
I found some problems in LazyJSON when trying to see if it can interwork with Unmarshal.jl, trying to reconstruct Julia objects from JSON serialization of the objects.
Conversion to Float32 is not supported and conversion to Float64 does a non-standard ?conversion which causes the reconstructed values to differ for some Float64 values.
See below:
It seems that LazyJSON's conversion from LazyJSON.Number{String} to Float64 is different from the other JSON packages.
I did a single line change to support Float32 conversion, which I will submit as a PR. Then the last line works.
The text was updated successfully, but these errors were encountered: