相关疑难解决方法(0)

有人可以解释一下:0.2 + 0.1 = 0.30000000000000004?

可能重复:
浮点数是如何存储的?什么时候重要?

为什么Python解释器中会出现以下情况?

>>> 0.1+0.1+0.1-0.3
5.551115123125783e-17
>>> 0.1+0.1
0.2
>>> 0.2+0.1
0.30000000000000004
>>> 0.3-0.3
0.0
>>> 0.2+0.1
0.30000000000000004
>>> 
Run Code Online (Sandbox Code Playgroud)

为什么不0.2 + 0.1 = 0.3呢?

python math python-3.x

20
推荐指数
2
解决办法
2万
查看次数

标签 统计

math ×1

python ×1

python-3.x ×1