Python数学是错误的 [英] Python math is wrong

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

问题描述

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

Possible Duplicate:
Python rounding error with float numbers

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天全站免登陆