Why does Python return True
when I compare int
and float
objects which have the same value?
For example:
>&
From the documentation:
Python fully supports mixed arithmetic: when a binary arithmetic operator has operands of different numeric types, the operand with the “narrower” type is widened to that of the other, where plain integer is narrower than long integer is narrower than floating point is narrower than complex. Comparisons between numbers of mixed type use the same rule.
According to this 5*2 is widened to 10.0 and which is equal to 10.0 If you are comparing the mixed data types then the result will be considered on the basics of data type which is having long range, so in your case float range is more then int float max number can be --> 1.7976931348623157e+308 int max number can be --> 9223372036854775807
Thanks