【发布时间】:2021-02-13 20:46:25
【问题描述】:
我正在做一个测验,我想知道我是否能正确确定它。这些是选项:
See if a == b is true
Check if a - b == 0 is true
Check if ((a-b)*(a-b))/(a*a + b*b) is close to or is zero
Check a*b == a*a is true
None of the above
我尝试在 C++ 中比较浮点值和双精度值,但我没有成功使用任何给定的公式。我会说“以上都不是”,但我不知道它在其他语言中是如何工作的。我在某处读到 Java 可能会有所不同,但我会选择最后一个选项,因为通常其他答案是不正确的。你怎么看?
【问题讨论】:
-
“没有成功”是什么意思?你究竟尝试了什么,结果是什么,为什么结果不是你想要的?
标签: math floating-point compare computer-science