Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Unable to Deserialize some doubles e.g. "59.08634249999999" will be "5.90863425E+15" #243

Open
tomsoftware opened this issue Dec 15, 2020 · 2 comments

Comments

@tomsoftware
Copy link

tomsoftware commented Dec 15, 2020

Some Float-Point Numbers are not Deserialize correctly

Example:

var x = JsonSerializer.Deserialize<object>("{\"a\":59.08634249999999}");

will result in

{[a, 5.90863425E+15]}
@tomsoftware tomsoftware changed the title Unable to Deserialize some doubles e.g. "59.08634249999999" Unable to Deserialize some doubles e.g. "59.08634249999999" will be "5.90863425E+15" Dec 15, 2020
tomsoftware pushed a commit to tomsoftware/Utf8Json that referenced this issue Mar 30, 2021
@tomsoftware
Copy link
Author

@neuecc : It seems like you do not maintain this library anymore... that's a pity. Can you maybe note that on the readme page or name a new maintainer?

For example this Issue feels really bad cause it occurs only sporadically on some numbers (the example-number and it's number of digits was first triggert by simply using JSON.Stringify() ) and if no one is able to fix issues like this no one should use this library :-(

@alex-vorobyev
Copy link

Your example are deserialize correctly if use decimal type:

public class ClassA { public decimal A { get; set; } }

var x = JsonSerializer.Deserialize<ClassA>("{ \"A\": 59.08634249999999 }");

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants