#Precision of double, zero not zero
15 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @somber stirrup! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
You can either round or accept that doubles aren't perfect
I suggest the second
otherwise you'll be disappointed about 0.1 + 0.2
Alternatively use BigDecimal which is actually accurate but a lot slower
It surprised me a little :D, thank you, I will stay with doubles. Do you know how to prepare tests in JUnit, that handle it?
you can add an interval which means it is correct
expected <= actual + dt && expected >= actual - dt
where dt is an abitrary precision
(stands for delta)
Thanks 🙂