Python数学错了 [英] Python math is wrong

查看:17
本文介绍了Python数学错了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
浮点数的 Python 舍入错误

Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> 4.2 - 1.8
2.4000000000000004
>>> 1.20 - 1.18
0.020000000000000018
>>> 5.1 - 4
1.0999999999999996
>>> 5 - 4
1
>>> 5.0 - 4.0
1.0

为什么 Python 的数学计算错误?

Why is Python getting its maths wrong?

推荐答案

你在计算机科学方面达到了一个新的水平,你已经成年了.

You have reached a new level in computer science, and you are coming of age.

因此,您现在已准备好进行下一步.我已获得 BDFL 他本人的授权,可以向您透露以下超级机密文件.古人先懂后破译,现在,你也懂了!

You therefore are now ready for the next step. I have been authorized by the BDFL himself to reveal the following Super Secret document to you. The ancients understood it and deciphered it first, and now, so will you!

小心对待这份文件!仅与您认识的得出同样令人困惑的结论的人分享!

Treat this document with care! Only share this with people you know have reached the same baffling conclusions!

版主须知

此答案不代表 Stack Overflow 上的预期质量标准.然而,它却出人意料地拥有了自己的生命,现在仅作为历史意义而保存下来.

This answer is not representative of the expected quality standards on Stack Overflow. However, it has unexpectedly developed a life of its own and is solely preserved for historical significance now.

这篇关于Python数学错了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆