c - 运算符优先级(按位 '&' 低于 '==' )

标签 c bitwise-operators operator-precedence

在C语言中,为什么按位运算符(&和|)的优先级低于等于运算符(==)?这对我来说没有意义。

最佳答案

你需要问问 Brian Kernighan 或 Dennis Ritchie。
从这个论坛:http://bytes.com/topic/c/answers/167377-operator-precedence

The && and || operators were added later for their "short-circuiting" behavior. Dennis Ritchie admits in retrospect that the precedence of the bitwise operators should have been changed when the logical operators were added. But with several hundred kilobytes of C source code in existence at that point and an installed base of three computers, Dennis thought it would be too big of a change in the C language...

所以,这可能是一个原因?我猜是因为存在多层按位优先级(与关系比较不同),所以它存在于......永远......并且从未得到纠正。

关于c - 运算符优先级(按位 '&' 低于 '==' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4685072/

相关文章:

C - 以文本作为参数

c - 为什么将整数左移 24 位会产生错误的结果?

haskell - 如何在 GHCI 中发现函数的优先级和关联性?

php - 不同机器上的按位运算结果不同

haskell - Haskell 中运算符与匿名函数的优先级

c++ - 后缀递增和递减是从左到右关联还是相反?

c - 信号功能是否足够安全,可以忽略或恢复信号处理程序?

c - 如何创建一个非重复随机数数组

c - 是否使用 union 未定义行为访问结构上的特定数组索引?

java - 无法通过按位运算获得长整型值