16 ms·
Step one: You don't. At least, not exact numbers. You almost always have to round the numbers up, or just aproximate the value. So, while 1.2 + 2.3 != 3.5
by wheelerof4te 5y ago
Step one:
You don't. At least, not exact numbers. You almost always have to round the numbers up, or just aproximate the value.
So, while
1.2 + 2.3 != 3.5
this is always correct:
1.2 + 2.3 < 3.6
- eru 5y agoHow do you determine the fudge factor? Eg if you compare (x + 1.2) + (x + 2.3) < (2*x + 3.6) that goes wrong for big enough x.
- wheelerof4te 5y agoUse the round function in that case.
- eru 5y agoHow is that going to help? What precision do you want to round to? You know that at big enough values, floating point numbers are farther apart than integers?