双比0.2!= 0.2怎么样? [英] double compare 0.2 != 0.2 How?

查看:66
本文介绍了双比0.2!= 0.2怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作实时预订图表。即使我测试了每个方法和除了这个之外的每个语句,我仍然给了我错误,我今天早上做了这个。

假设这些语句是做什么的?

I''m working on a real-time reservation graph. And it keeps giving me error even I tested each Method and each statement except this one, which I did this early morning.
What suppose these statements do?

展开 < span class =codeDivider> | 选择 | Wrap | Line数字

推荐答案

因为0.2不能在浮点上精确表示,编译器会重新编写值并从两个双数字计算(其中0.8也不能重复确切),必须有一些差异。


如需在线帮助,请检查 http://www.h-schmidt.net/FloatApplet/IEEE754.html 或阅读维基百科。
Because 0.2 cannot be represented exact on floating point, value readed by the compiler and calculated from two double numbers (where 0.8 cannot also be repsesented exact), there has to be some differences.

For online help, check http://www.h-schmidt.net/FloatApplet/IEEE754.html or read wikipedia.


什么错误你得到了吗?

编辑:NM我看到
What error are you getting?
NM I see


太棒了我知道浮点数的表示。但我该怎么办?!

我正在比较两个双数并得出错误的结果。

任何想法。我不能退一步,我的申请取决于那个比较。
Great I know the representation of a floating-point number. But What should I do?!
I''m comparing two double numbers and get wrong result.
Any idea. I can''t step back for that, my application depends on that comparison.


这篇关于双比0.2!= 0.2怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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