更新时间:2022-12-09 20:41:12
在C99§6.5.8关系运算符,项目6(<
,>
,< =
和> =
)
In C99 §6.5.8 Relational Operators, item 6 (<
,>
,<=
and >=
):
每个运营商和LT的; (小于),>(大于),LT =(小于或等于),和> =
(大于或等于)应产生的 1 如果指定的关系是真实和 0 如果是假的)
结果类型的内部
Each of the operators < (less than), > (greater than), <= (less than or equal to), and >= (greater than or equal to) shall yield 1 if the specified relation is true and 0 if it is false) The result has type int.
至于平等的运营商,这是一个有点进一步§6.5.9( ==
和!=
)
As for equality operators, it's a bit further in §6.5.9 (==
and !=
):
的==(等于),!=(不等于)运算类似于关系
除了其较低的precedence运营商)各运营商产量的 1 如果在中
指定的关系是真实和 0 如果是假的。结果类型的内部即可。对于任何一对
操作数的关系,只有一个是真的。
The == (equal to) and != (not equal to) operators are analogous to the relational operators except for their lower precedence) Each of the operators yields 1 if the specified relation is true and 0 if it is false. The result has type int. For any pair of operands, exactly one of the relations is true.
的逻辑与和逻辑或尚未有点进一步§6.5.13(&放大器;&安培;
)
The logical AND and logical OR are yet a bit further in §6.5.13 (&&
)
&将功放;&安培;经营者应当产生的 1 如果两个操作数的比较不等于0;否则,它
收益率 0 。结果类型的内部
The && operator shall yield 1 if both of its operands compare unequal to 0; otherwise, it yields 0. The result has type int.
...和§6.5.14( ||
)
... and §6.5.14 (||
)
该||经营者应当产生的 1 如果任一操作数的比较不等于0;否则,它
收益率 0 。结果类型的内部
The || operator shall yield 1 if either of its operands compare unequal to 0; otherwise, it yields 0. The result has type int.
和一元算术运算符的语义
超过在§6.5.3.3/ 4:!
And the semantics of the unary arithmetic operator !
are over at §6.5.3.3/4:
逻辑否定运算符的结果!为 0 如果操作数的值进行比较
不等于0, 1 如果它的操作数的值进行比较,等于0的结果类型的内部即可。
这位前pression!E是等于(0 == E)。
The result of the logical negation operator ! is 0 if the value of its operand compares unequal to 0, 1 if the value of its operand compares equal to 0. The result has type int. The expression !E is equivalent to (0==E).
结果类型为 INT
一刀切,用 0
和 1
作为可能的值。 (除非我错过了一些。)
Result type is int
across the board, with 0
and 1
as possible values. (Unless I missed some.)