Why do bitwise logical operators in C have a priority lower than or equal

Source: Internet
Author: User

Http://www.cnblogs.com/aoaoblogs/archive/2012/05/02/2478758.html

 

 

Early C has distinguished logical operations from operators &/| and bit logical operations &/|, (Do you know ?). & And | use the "true context" (inherited from B and BCPL) to explain its meaning: If it is behind "if" and "while, because it must be a Boolean expression, both & and | are regarded as the current & and | in the explanation; in the normal expression, & and | are interpreted as bit logical operations. This method is not bad, except for some obstacles to understanding. (There was the notion of "top-level operators" in a truth-value context. 
)

At that time, the priority of & and | was the same as that of the current & and |. Under the strong requirement of Alan Snyder, & | is added to C, which separates bitwise logical operators from logical operators. However, I always have a cold foot to catch up with this priority problem. For example, we will see a lot of soy sauce. Code: If (A = B & C = d )... (shake ...) now we can see that the priority of & may be increased to higher than =, but at that time, we may just make a distinction between & and, do not modify the priority of existing & operators to be more secure. (After all, we have thousands of source code .. Maybe 3 installations...
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.