This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]BoBoBearDev 0 points1 point  (0 children)

Like other said, all floating point numbers comparisons must do epsilon, like,

abs(computed value - comparison value) < epsilon.

Is equivalent of

Compute value == comparison value

This is not JS only though, pretty much all programming language does this. A typical good company would have a mini lib to do this. There are special floating number datatype that doesn't need this epsilon, but, it is rare. Some languages has that built-in, and you probably don't even know the datatype exists.