Floating point numbers in Python and most of the modern langua | Python etc
Floating point numbers in Python and most of the modern languages are implemented according to IEEE 754. The most interesting and hardcore part is "arithmetic formats" which defines a few special values:
+ inf and -inf representing infinity. + nan representing a special "Not a Number" value. + -0.0 representing "negative zero"
Negative zero is the easiest case, for all operations it considered to be the same as the positive zero:
-.0 == .0 # True -.0 < .0 # False
Nan returns False for all comparison operations (except !=) including comparison with inf: