JuliaIO / JSON.jl

JSON parsing and printing
Other
313 stars 101 forks source link

Error parsing very precise float #296

Closed DatName closed 4 years ago

DatName commented 4 years ago

Parsing

{
    "amount": 99233885.0302231276962159466369304902338091026
}

results in

ERROR: InexactError: Int64(13638601307514633761)
Stacktrace:
 [1] Type at ./gmp.jl:356 [inlined]
 [2] roundQuotient(::BigInt, ::BigInt) at ~/.julia/packages/Parsers/4gpBu/src/floats.jl:288
 [3] scale(::Type{Float64}, ::BigInt, ::Int64) at ~/.julia/packages/Parsers/4gpBu/src/floats.jl:371
 [4] scale at ~/.julia/packages/Parsers/4gpBu/src/floats.jl:387 [inlined]
 [5] typeparser at ~/.julia/packages/Parsers/4gpBu/src/floats.jl:194 [inlined]
...

while

julia> parse(Float64, "99233885.0302231276962159466369304902338091026")
9.923388503022313e7
quinnj commented 4 years ago

Thanks for the report; fix is up here: https://github.com/JuliaData/Parsers.jl/pull/43.