为什么 (x – y <= j - k - 1) 的计算结果为假?

huangapple go评论73阅读模式
英文:

Why does (x – y <= j – k – 1) evaluate to FALSE?

问题

以下是:

什么正在这里发生?

下面是

int i = 1, j = 2, k = 3;  
double x = 5.5, y = 7.7;

x - y <= j - k - 1 FALSE

-i + 5 * j >= k + 1 TRUE
英文:

What is happening here?

Below is the

int i = 1, j = 2, k = 3;  
double x = 5.5, y = 7.7;

x - y &lt;= j - k - 1 FALSE

-i + 5 * j &gt;= k + 1 TRUE

答案1

得分: 2

它(显然)不会:

class Test {
public static void main(String[] args) {
int i = 1, j = 2, k = 3;
double x = 5.5, y = 7.7;

    System.err.printf("%f <= %d: %s\n", x - y, j - k - 1, x - y <= j - k - 1);
}

}


产生的输出:

```plain
-2.200000 <= -2: true

但请注意,您发布的代码包含无效的Unicode字符,这将导致编译错误。


<details>
<summary>英文:</summary>

It (obviously) doesn’t:

class Test {
public static void main(String[] args) {
int i = 1, j = 2, k = 3;
double x = 5.5, y = 7.7;

	System.err.printf(&quot;%f &lt;= %d: %s\n&quot;, x - y, j - k - 1, x - y &lt;= j - k - 1);
}

}


yields:

```plain
-2.200000 &lt;= -2: true

But note that the code you’ve posted contains invalid Unicode characters that would lead to a compilation error.

huangapple
  • 本文由 发表于 2020年10月5日 20:11:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/64208382.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定