python有关浮点数的误差是这么说的:
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
见这里 https://docs.python.org/2/tutorial/floatingpoint.html
你可以试试Decimal, 估计底层没有完全实现一个完整的大数算法,实际上,我觉得这个并不完全是Python规范的内容,而是取决于平台和实现,你可以看下当前平台的float大小
import sys
print sys.float_info
sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)
python手册里如是说
Floating point numbers are usually implemented using double in C; information about the precision and
internal representation of floating point numbers for the machine on which your program is running is available in
sys.float_info.
上面说的这些都是CPython的实现,而这个在Jython中,又是另一番定义:
Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:48:36)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_40
Type "help", "copyright", "credits" or "license" for more information.
>>> '%.100f' % (9999.0/10000)
'0.9999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
结论: 这个取决于平台实现。