Skip to content

Double parsed with trailing zeros #206

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

Closed
robbienohra opened this issue Sep 4, 2018 · 0 comments
Closed

Double parsed with trailing zeros #206

robbienohra opened this issue Sep 4, 2018 · 0 comments

Comments

@robbienohra
Copy link

robbienohra commented Sep 4, 2018

Some double values trigger trailing zeros when deserialized.

"field": 1.2932 (of type Double)

Is parsed as 1.2932000000000001

If you change the field to type Float then the value is correctly parsed.

Again only certain numbers appear to be triggering this.

You can replicate the issue like this.

Define:

class Obj {

  Double field;

}

Then execute:

String json = "{ \"field\" : 1.2932}";
Obj obj = JsonIterator.deserialize(json,Obj.class);
System.out.println(obj.getField());
//  1.2932000000000001

Same issue arises even if you use the Any api.

@robbienohra robbienohra changed the title Double parsed with trailing zeros? Double parsed with trailing zeros Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant