Detailed description of C-language operation symbols

Source: Internet
Author: User

The operators in C that have right-associative features include all monocular operators as well as assignment operators (=) and conditional operators. Others are left-associative.

When judging the order of the expression evaluation, first the first high priority calculation, the lower priority after the calculation, when the priority is the same, then by the combination, or from left to right order, or from right to left in the order of calculation.

Symbols in the C language
Types of Operators
The language operators can be divided into the following categories:

1 Arithmetic operators
Used for various numerical operations. Including plus (+), minus (-), multiply (*), except (/), balance (or modulo operation,%), self-increment (+ +), auto Minus (–) a total of seven.

2. Relational operators
Used for comparison operations. Include greater than (>), less than (<), equals (= =), greater than or equal (>=)
, less than Equals (<=), and not equal to (! =) Six.

3. Logical operators
Used for logical operations. Included with (&&), or (| |), non-(!) Three kinds.

4. Bitwise MANIPULATION Operators
The number of participating operations is calculated by bits. There are six kinds of bits and (&), bit or (|), bit non (~), bit xor (^), left (<<), right Shift (>>).

5. Assignment operators
For assignment operation, there are 11 kinds of three classes: simple Assignment (=), compound arithmetic Assignment (+=,-=,*=,/=,%=) and compound bit operation Assignment (&=,|=,^=,>>=,<<=).

6. Conditional operators
This is a three-mesh operator for conditional evaluation (?:).

7. Comma operator
Used to combine several expressions into an expression (,).

8. Pointer operators
Used to fetch the contents (*) and Fetch address (&) Two kinds of operations.

9. The number of bytes operator
The number of bytes (sizeof) used to calculate the data type.

10. Special Operators
with parentheses (), subscript [], member (→,.) and several others.

Priority ordering:

Priority level 1 combination direction left associative (left to right) edit () parentheses [] [1] subscript operator--point to struct member operator. struct member operator [1] (Note that it is a solid dot) Priority 2-level combined direction right-associative (right-to-left) Monocular operator edit! Logical non-operator ~ bitwise INVERSE operator + + self-increment operator-- Self-decrement operator- Minus sign operator (type) type conversion operator* Pointer operator & address operator sizeof length operator Precedence 3-level union direction left associative binocular operator edit* Multiplication operator/division operator% take-out operator precedence 4 level union direction left associative binocular operator edit + addition operator- Subtraction Operator Precedence 5-level union direction left-associative binocular operator edit << left shift operator >> right-shift operator priority 6-level union direction left associative binocular operator Edit <, <=, >, >= relational Operator precedence 7-level combination direction left combined binocular operation operator editing= = equals operator (judging)! = Not equal to operator (judge) Priority 8-level union direction left associative binocular operator edit & Bitwise-Operator Precedence 9-level union direction left-Associative binocular operator Edit ^ bitwise XOR OR Operator precedence 10-level union direction left-Associative binocular operator edit | Examples of bitwise OR operators: 0XFE|0XEF is 1111 1110 and 1110 1111 bitwise OR operation the answer is: 1111 1111 is 0xFF. Priority level 11 combination direction left associative binocular operator edit && logical AND Operator precedence 12-level union direction left associative binocular operator edit | | Logical OR Operator precedence 13-level combination direction right combined with trinocular operator edit? : conditional operator Precedence 14-level combination direction right-associative binocular operator edit= assignment operator+ = post-add assignment operator such as S+=1 says S=s+1- = minus-after assignment operator, such as S-=1, represents s=s-1* = Multiply-after assignment operator/= after assignment operator% = modulo assignment operator < <= assignment operator after left shift >>= right-shift assignment operator &= bitwise-and post-assignment operator |= bitwise-or post-assignment operator precedence 15-level Union direction left Combine edit, comma operator

Description
Operators of the same precedence, the order of operations is determined by the binding direction.
Simple Note is:! > Arithmetic operators > Relational operators > && > | | > Assignment Operators

Copyright NOTICE: This article is for bloggers original articles, reproduced please attach the original link, thank you.

Detailed description of C-language operation symbols

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.