-2
我想添加两个浮动数字,我无法去工作。我需要的输出是100.0 我在这里做错了什么。感谢您的任何建议。.01蟒蛇加法的价值是什么
mystring = 'Value: 99.9 Date: 20130215'
tot = float(mystring[8:13])
print (float(tot) + .01)
我需要的TOT = 100.0,如果任何一个可以帮助谢谢
我得到99.91
我想添加两个浮动数字,我无法去工作。我需要的输出是100.0 我在这里做错了什么。感谢您的任何建议。.01蟒蛇加法的价值是什么
mystring = 'Value: 99.9 Date: 20130215'
tot = float(mystring[8:13])
print (float(tot) + .01)
我需要的TOT = 100.0,如果任何一个可以帮助谢谢
我得到99.91
两个问题:
更多关于(2),见floating point arithmetic
99.9 + 0.01也不是100,这是99.91 – 2014-10-16 18:41:11
我建议阅读[浮动点关节类型](https://docs.python.org/2/tutorial/floatingpoint.html)文档 – Grice 2014-10-16 18:41:15
你不应该加0.1而不是0.01吗? – pjd 2014-10-16 18:41:16