开发者

What is float('123.987') in Python?

开发者 https://www.devze.com 2022-12-25 07:57 出处:网络
It\'s 开发者_高级运维123.98699999999999 ! Why is that?See Why can\'t decimal numbers be represented exactly in binaryThe Python FAQ and tutorial address this issue pretty well, I think.More generally

It's 开发者_高级运维123.98699999999999 !

Why is that?


See Why can't decimal numbers be represented exactly in binary


The Python FAQ and tutorial address this issue pretty well, I think. More generally, both are excellent resources, well worth your time to browse if you have any interest in Python!-)


This has changed in/since Python 3.1.

See also: issue 1580


To your (already deleted) addition: Use the decimal package.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号