The shift operator is also for the binary "bit", which mainly includes the left shift operator (>>), and the signed right shift operator (>>).
1. Left shift operatorThe left-shift operator, represented by "public class Data17{public static void
About the shift left operator in C language, the shift left Operator
Referring to c and pointer, the result of left shifting in c language is the same regardless of arithmetic or logical left shifting. In addition, perform the same operation for the
The bitwise shift operator is an operation that moves the data as a binary number, moving it to the left or right several bits. The bit shift operators are divided into left and right shifts, both of which are binocular operators. The first
No matter left shift or right shift, the result's sign shoshould always be the same as its left operand. By default, const numbers in C/C ++ is signed.
-Wsign-compare{Unsigned Int J = 3; int K = 5; If (j = (1 1); If (j = (k> 1); // warning:
The following code:public class Example027 {public static void main (string[] args) {int i = 0;while ( -1 Result Description: put the above program into eclipse, and the output line will prompt "unreachable code". That is, the while loop is a dead
Displacement operatorThe essence of the left shift operation is to shift the binary value of the corresponding data to the left bit by bit, and fill 0 in the vacated position, the highest bit overflow and discard. For example$a = 10;$b = $a Then $b=4
The object of the shift operator operation is the binary bit, which can be used to handle int integers with the shift operator alone.
Operator
Meaning
Example
Left-shift operator, moves the left-hand
1, left shift operation
The left shift operation is represented by a two less-than sign (
var iOld = 2; Bits 10
var iNew = iOld
Note that when you move the digits to the left, there are 5 more vacancies on the right side of the number. The left-
Both the left and right shifts are the concepts of bit operations. We know that computers store data based on binary, so the concept of left and right shifts is important. This article deals with a 32-bit machine. [left] discard highest bit, 0
Let's say move left, move left to shift all bits of a number to the left, and in C with the int i = 1;i = i In other words, 1 of the 2 binary is 000 ... 0001 (here 1 the number of front 0 is related to the number of int, 32-bit machine, GCC has 31 0)
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.