>>> num = 4.123456
>>> round(num, 3) # expecting 4.123
4.1230000000000002
我期望结果是 4.123,我错了吗?
请您参考如下方法:
这不是错误。您需要阅读 What Every computer Scientist Should Know About Floating Point Arithmetic:
>>> num = 4.123456
>>> round(num, 3) # expecting 4.123
4.1230000000000002
我期望结果是 4.123,我错了吗?
请您参考如下方法:
这不是错误。您需要阅读 What Every computer Scientist Should Know About Floating Point Arithmetic: