浮点数字 [英] Floating Point Numbers

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

问题描述

所以我正在阅读这个PDF教程:学习Python第四版。现在我到了一个我不明白的地方,因为我几乎是Python的初学者。我正在谈论这个部分:



现在我没有得到第一个例子的解释。它的确如下所示:
事实证明,有两种方法可以打印每个对象:完全精确(如这里显示的第一个结果)



但是这个如何具有完全精度?



解释方法

基本上,计算机的浮点运算有四舍五入错误。所以如果你执行 1. * 1000. / 1000。,你可以用 1.0000004 或类似的东西来结束。这是电脑在内存中存储的内容。但是,您可能不希望看到1.0000004作为计算的结果。所以当你打印结果时,计算机会进行四舍五入,你会得到简单的 1 。但是你必须知道它并不是计算机内存中的真正价值 - 它只是你的实际浮点数的一个舒适的可视化。


So I am reading this PDF tutorial called: "Learning Python Fourth Edition". Now I got to a part which I dont understand because I am pretty much a beginner in Python. I am talking about this part:

Now I dont get the explaining of the first example. It does say: It turns out that there are two ways to print every object: with full precision(as in the first result shown here)

but how is this with full precision?

It might just explain it very easily for python programmers in the text but I dont seem to get it.

解决方案

Basically, the computer's floating point calculations have rounding errors. So if you perform 1.*1000./1000., you can end up with 1.0000004 or something like that. It is what the computer stores in the memory. However, you probably don't want to see 1.0000004 as a result of that calculation. So when you print the result, the computer does the rounding, and you will get simply 1. But you have to know that it is not the real value in the computer's memory - it is only a comfortable visualization of your actual floating point number.

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

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