DEV Community

Discussion on: How to compare numbers correctly in JavaScript

Collapse
 
manlycoffee profile image
Sal Rahman

Thanks for the article. It opened me up to the opportunity to look around, and I've found an article that proposes a potential solution to the problem that you posed in yours. That is, the epsilon comparison can have an additional step of multiplying it with the largest of the two operands. This way, the tolerance can be adjusted according to the operands that are supplied to the equality check.

Take a look. randomascii.wordpress.com/2012/02/...