question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`BigDecimal("1.199999988079071").floatValue shouldBe 1.199999988079071f` fails

See original GitHub issue

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sjrdcommented, Sep 6, 2022

I’m not questioning whether this bug is worth fixing. It’s a bug, and we fix all bugs.

I’m wondering if doing java.lang.Float.parseFloat(toString()) is an acceptable implementation. Because it does fix the issue (I tried).

Why do circe and play-json use BigDecimal to then lose all their precision to floats, of all things? Is that the expected fast path people will use in the common case?

0reactions
armanbilgecommented, Sep 6, 2022

Why do circe and play-json use BigDecimal to then lose all their precision to floats, of all things? Is that the expected fast path people will use in the common case?

I can’t speak for play-json, but IIRC Circe uses BigDecimal for its internal Json representation to maintain precision. Of course, a user is then free to decode that to any numerical type (which may be Float).

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found