C-language operator precedence, binding (left/right combination) __c language

Source: Internet
Author: User
Tags arithmetic operators bitwise

Back to the C language, feel that the combination of C language operators it is necessary to mention, after all, last year I just learned the C language, I did not understand the problem of integration.

What is left binding. What is the right combination. What are they used for? When they were used.

This article will focus on these issues.

(Small Bai, great God bypass)

First of all, appendix A few of your own learning process reference website. (Some insights and examples from the website)

Http://wenku.baidu.com/link?url=W2ofiBx4yEtrxAAfV8lUaR-bYSIuBox1_ Dh-1mg6g6q0venbr31ofklauxrq6arqmjeo-r1hvvybjxvvvtfasi5cxi4merolvxzs3yzrtis



before talking about the binding, first mention the C language operator and its precedence relationship.

C-language operator precedence

Priority Level


name or meaning

Use Form

Combining Direction




Array subscript

array name [constant expression]

Left to right




(expression)/function name (formal parameter list)



Member selection (object)

Object. Member name



Member selection (pointers)

Object pointer-> member name




Minus sign operator

-An expression

right to left

Monocular operator


Bitwise inverse operator

~ Expression


Self-increasing operator

+ + variable name/variable name + +


Self-subtraction operators

--Variable name/variable name--


Value operator

* Pointer variable


Take address operator

& Variable Name


Logical non-operator

! An expression


Force type conversions

(data type) expression



Length operator

sizeof (expression)





An expression/expression

Left to right

Binocular operator



Expression * Expression


Remainder (modulo)

Integral expression% integer expression




expression + expression

Left to right

Binocular operator



Expression-An expression



Move left

Variables << expressions

Left to right

Binocular operator


Move right

Variables >> expressions



Greater than

Expressions > expressions

Left to right

Binocular operator


Greater than or equal to

Expression >= An expression


Less than

Expressions < expressions


Less than or equal to

Expression <= An expression




expression = = Expression

Left to right

Binocular operator

. =

Not equal to

Expression!= An expression



Bitwise AND

Expressions & Expressions

Left to right

Binocular operator



Per-bitwise XOR OR

expression ^ expression

Left to right

Binocular operator



by bit or


Left to right

Binocular operator



Logic and

Expressions && Expressions

Left to right

Binocular operator



Logical OR

expression | | An expression

Left to right

Binocular operator



Conditional operator

Expression of 1?

Expression 2: Expression 3

right to left

Three-mesh operator



Assignment operator

variable = expression

right to left



Assign value in addition to

Variable/= expression



After multiplication assign value

Variable *= expression



To assign a value after taking a model

Variable%= expression



Add and then assign value

Variable = = Expression



After minus assignment

Variable-= expression



Assign values after left shift

Variable <<= expression



Assign value after right shift

Variable >>= expression



Bitwise AND Post-assignment

Variable &= expression



Assign values by bitwise OR after

Variable ^= expression



Bitwise OR post-value assignment

Variable |= expression




Comma operator

expressions, Expressions,...

Left to right




operators are divided into 15-level, 1-level priority highest, 15-level priority lowest.

operator of the same priority, the order of operations is determined by the binding direction. (Binding: 2 13 14 is from right to left the other is from left to right)
The simple note is:. > Arithmetic operators > Relational operators > && > | | > Assignment Operators

a little more detail, with a formula. (found on the Internet)

Bracket member first                //bracket operator [] () member operator.
/strong> All monocular second              //all monocular operators such as + +,--、 + (positive),-(negative), pointer operation *, & Division and Division Yusan, plus minus four;        /This "Yu" refers to the remainder operation that is%

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.