It's OK to compare floating-points for equality (lisyarus.github.io)
from soc@programming.dev to programming@programming.dev on 16 Apr 11:05
https://programming.dev/post/48902840

#programming

threaded - newest

MonkderVierte@lemmy.zip on 16 Apr 11:45 next collapse

Say, you have a turn-based game where units move on a grid. … Then you realize that the move finishes exactly when the position of the unit coincides with the target cell’s center.

I mean, something like inbetween(target - cellRadius, target + cellRadius), no?

And of course you first (and generally) convert the floating points to units you can actually work with, why is this even a question? Anyone who knew KSP as more than a rocket explosion simulator, learned that lession long ago from the Kraken.

Blue_Morpho@lemmy.world on 16 Apr 12:44 collapse

That’s one case study. He lists many more where throwing an epsilon at a floating point problem is the wrong solution.

[deleted] on 16 Apr 12:14 next collapse
.
calcopiritus@lemmy.world on 16 Apr 18:31 collapse

Headline: says something. (That is obviously not true and just clickbaiting)

Instant disclaimer: the headline is not good, it should be instead “don’t do this other thing”.

Later in the article: how do we avoid doing the thing I told you not to do? By doing what I told you not to do.

The dude may be correct (idk, haven’t bothered reading the rest of the article), but he doesn’t know how to write/communicate. I don’t believe he’s respecting my time. Just tell in the title what you actually want to talk about.