gpt4 book ai didi

c++ - "compares less than 0"是什么意思?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:10:47 24 4
gpt4 key购买 nike

上下文

当我在阅读时 Consistent comparison ,我注意到动词 to compare 的一种特殊用法:

There’s a new three-way comparison operator, <=>. The expression a <=> b returns an object that compares <0 if a < b, compares >0 if a > b, and compares ==0 if a and b are equal/equivalent.

在互联网上找到的另一个例子(重点是我的):

It returns a value that compares less than zero on failure. Otherwise, the returned value can be used as the first argument on a later call to get.

最后一个example ,在 GitHub 上找到(重点是我的):

// Perform a circular 16 bit compare.
// If the distance between the two numbers is larger than 32767,
// and the numbers are larger than 32768, subtract 65536
// Thus, 65535 compares less than 0, but greater than 65534
// This handles the 65535->0 wrap around case correctly

当然,对于有经验的程序员来说,意思是很清楚的。但是在这些示例中使用动词 to compare 的方式在任何标准英语形式中都不标准。

问题*

  • 如何编程jargon句子“The object compares less than zero”翻译成简单的英语
  • 这是否意味着如果将对象与0 进行比较,结果将“小于零”?
  • 为什么说“对象小于零”而不是“对象比较小于零”是错误的?

* 我在 English Language Learners 上寻求帮助和 English Language & Usage .

最佳答案

“compares <0”用简单的英语就是“比较小于零”。

我相信这是一个常见的速记。

所以将这个应用到整个句子中得到:

The expression a <=> b returns an object that compares less than zero if a is less than b, compares greater than zero if a is greater than b, and compares equal to zero if a and b are equal/equivalent.

这真是一口。我明白为什么作者会选择使用符号。

关于c++ - "compares less than 0"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47498486/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com