# A brief introduction to the operation of various bit operators in C language

Source: Internet
Author: User

Operator :

arithmetic operators : +,-, *,/,%, + +,--

compliant operators : + =, *=,/=,%=

conditional operator :? :

relational operators : = =, >=, <=,! =, >, <

logical operators : &&, | | , !

assignment operator : =

Other operators : *, &,.

Bitwise operators :

1 > bitwise AND & at the same time for one or the other is zero 3 & 5 result is 1 ( two digits are first calculated in binary )

3 > 0000 0011

5 > 0000 0101 Binary then follow the same line for one or zero to 0000 0001

after conversion, it becomes 1;

generally used to clear 0 operation .

2 > Bitwise or | The same as 0 is 0 otherwise 1 9 | 5 9 > 00001001

|

5 > 00000101

=00001101 13

3 > bitwise XOR or difference is 1, the same is 0;

9 ^ 5 0000 1001

0000 0101

0000 1100 = 8 + 4 = 12;

4 > Bitwise Reverse ~ 1 to 0 0 to 1 for a single number

5 > shift left <<

High-level discard , low- fill 0

High Low

9 > 0000 0000 0000 1001

9 << 3 0000 0000 0100 + 8 = 9 * 2 3 - time equivalent

M << N is equivalent to the n- th square of M * 2.

6 > Right Shift >>

low Discard , high 0 ( positive ) or 1 ( negative )

the signed bit sign bit follows the move .

10

Original Code : The original code is itself binary 0000 1010

complement : ( all the numbers , stored in memory are in the form of a complement .)

1 > Positive : the complement of positive numbers is the same as the original code

2 > Negative numbers: the complement of negative numbers , the sign bit unchanged, the numerical part , and the inverse plus 1;

example : -10 of the Code

10000000 00000000 00000000 00001010

11111111 11111111 11111111 11110101

+1

11111111 11111111 11111111 11110110

Stored in accordance with the system (4 + 2)

FF FF FF F 6 (F6)

Some computers are stored in reverse.

F6 FF FF FF

Anti-code :

1 > Positive Inverse code is the same as the original code .

2 > negative Inverse code , sign bit unchanged, value part inverse

C Language Program edit the process of execution :

1 > Programmer's Coding area ;(Coding, the code );

2 > Pre- processing ( precompiled )

3 > compiled into assembly code

4 > assemble code into target file

5 > the target file and the attached library file link to form the executable file .

A brief introduction to the operation of various bit operators in C language

Related Keywords:
Related Article

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.