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
|
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 aBigDecimalusingBigDecimal.decimalrather thanBigDecimal(see documentation there).see #109