underlying data structure for float in python
问题 Got a question regarding to the underlying data structure of float (and precision) in Python: >>> b = 1.4 + 2.3 >>> b 3.6999999999999997 >>> c = 3.7 >>> c 3.7000000000000002 >>> print b, c 3.7 3.7 >>> b == c False it seems the values of b and c are machine dependent, they are the numbers that closest to the target values but not exactly the same numbers. I was supervised that we get the 'right' numbers with 'Print', and someone told me that it was because print 'lies' while Python chose to