News for hackers. Stuff that matters.
Re:How to compare floats in Python by wheelerof4te on Wednesday March 30, 2022 @04:19PM (#30860277)
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
Re:How to compare floats in Python by eru on Thursday March 31, 2022 @01:55AM (#30864238)
How 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.

Re:How to compare floats in Python by wheelerof4te on Thursday March 31, 2022 @06:14AM (#30865561)
Use the round function in that case.
Re:How to compare floats in Python by eru on Thursday March 31, 2022 @07:58PM (#30873653)
How 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?