-
Notifications
You must be signed in to change notification settings - Fork 190
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
Correctly convert a Float to a JsNumber using BigDecimal#decimal #241
Correctly convert a Float to a JsNumber using BigDecimal#decimal #241
Conversation
Verified that this indeed makes a difference, without it we'd get |
Thanks! |
Failure seems to be MiMa, but not about any method that was touched in this PR... will fix separately |
2.10 build failed. This addition would mean that we're not compatible with Scala 2.10 anymore. https://travis-ci.org/spray/spray-json/jobs/302117152
|
sry, forgot about 2.10. Changed the code to not use |
Nice, AFAICS that's correct (and what BigDecimal.decimal does inside anyway), let's have the tests pass but looking good |
tests seem to pass, but some other check failed |
let me know if there is anything else that needs to be changed |
@ktoso, any news on if/how/when this can be merged? It'd be useful for some cases here, not urgent though. |
543ca93
to
c994751
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @lars-n even after all this time ;) (Rebased and removed whitespace changes)
I already forgot about this one 😃 . Thanks @jrudolph |
When converting Floats to a JsNumber they will not be converted exact. The issue appears to be in
JsNumber.apply
(https://github.com/spray/spray-json/blob/master/src/main/scala/spray/json/JsValue.scala#L97) where the Float should be converted to aBigDecimal
usingBigDecimal.decimal
rather thanBigDecimal
(see documentation there).see #109