I read that comparing two floats using == in python can lead to errors. But what about using that operator in integers ? Thanks
Because I never found anything against the use of the operator I believe that is okay to use.
I read that comparing two floats using == in python can lead to errors. But what about using that operator in integers ? Thanks
Because I never found anything against the use of the operator I believe that is okay to use.
Yes, it's fine. The int
type in Python doesn't have the representational problems that float
has.
But an interesting bit of trivia is that float
types with an integer value are safe to compare too, as long as they're less than 2**53 (9007199254740992).