DEV Community

Discussion on: Do you ever need to equally compare numbers (floating points)?

Collapse
 
mateuszjarzyna profile image
Mateusz Jarzyna

If you have to compare two numbers you should use some epsilon (depends on your needs).
But there are some cases where you should not use float numbers - for example money.

BTW, there is the simplest way to write the comparator abs(a - b) <= epsilon.