Priority of << in C + +

Source: Internet
Author: User

Find << priority is very low ... Or am I too ignorant ...

#include <stdio.h>
#define GET_BIT(a, b, c) a << b - c
int main()
{
int a = 1;
int b = 5;
int c = 4;
printf("%d\n", GET_BIT(a, b, c) + 1);
}
result: 4

C's Priority formula

Bracket members first; Bracket operator [] () member operator. ->

All monocular second; All monocular operators such as + +,--、 + (positive),-(negative), pointer operation *, &

Multiplication and division Yusan, plus minus four; This "Yu" means the remainder operation, i.e.%

Shift five, relationship six; Shift operators:<< >>, Relationship:> < >= <= etc.

Equal to (with) unequal row seventh; that is = = = and!=

Bit with XOR or bit or; These are bitwise operations: Bits and (&) or (^) bits or (|)

"Three points World" eighty or ninety;

The logic or the heel; Logical operators: | | and &&

12 and 11; Note Order: Priority (| |) at the bottom of priority (&&)

The condition is higher than assignment,//three mesh operator precedence to 13 bits is only higher than assignment operator and ","

The lowest comma operation level! The comma operator has the lowest precedence

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.