据我所知,只有-73.81632995609999是唯一一个断开的数字,而且它的降幅很小。这是一个有很好文档记录的问题,它是由于Python如何显示浮点数而产生的。从python website:On a typical machine running Python, there are 53 bits of precision available for a Python float, so the value stored internally when you enter the decimal number 0.1 is the binary fraction
0.00011001100110011001100110011001100110011001100110011010 which is close to, but not exactly equal to, 1/10.
It’s easy to forget that the stored value is an approximation to the original decimal fraction, because of the way that floats are displayed at the interpreter prompt. Python only prints a decimal approximation to the true decimal value of the binary approximation stored by the machine. If Python were to print the true decimal value of the binary approximation stored for 0.1, it would have to display
>>> 0.1
0.1000000000000000055511151231257827021181583404541015625
更具体地说,关于小表示错误:Representation error refers to the fact that some (most, actually) decimal fractions cannot be represented exactly as binary (base 2) fractions. This is the chief reason why Python (or Perl, C, C++, Java, Fortran, and many others) often won’t display the exact decimal number you expect:
>>> 0.1 + 0.2
0.30000000000000004
Why is that? 1/10 and 2/10 are not exactly representable as a binary fraction. Almost all machines today (July 2010) use IEEE-754 floating point arithmetic, and almost all platforms map Python floats to IEEE-754 “double precision”. 754 doubles contain 53 bits of precision, so on input the computer strives to convert 0.1 to the closest fraction it can of the form J/2**N where J is an integer containing exactly 53 bits.
简而言之,这种修改是因为Python如何存储数字。你可以试着乘以10^n并将这些值存储为整数,然后在需要计算时进行除法。如果您在进行简单的计算,python所产生的微小差异不会对这些计算产生实质性的影响。希望这有帮助。在