|
|
|
|
|
by minipci1321
3461 days ago
|
|
C for sure has its weird sides, but does appear much more logical and consistent when observed "from the below", from how-the-hardware-runs perspective. For example, the shift operators have higher precedence than bitwise masking (and/or/xor) since this way the expressions setting/clearing ranges of bits won't require parentheses (so increased readability) and the masking constants in them will be the narrowest. Loading a wide immediate value into a register sometimes takes several instructions, so such precedence also brings in the least cost as well (nowadays compilers take care of that to some extent). But people frequently mess up this aspect, use lots of parens (and ending up with wide masks) saying this rule is not intuitive. It is. |
|