Back to directory
In this article, "2" refers to binary, that is, when we see 2, it is also called every two, and it is the simplest and clearest data. In real life, the most commonly used data is decimal data, that is, every 10 to one. Let's take a look at the example:
Binary: decimal
0 0
01 01
10 02
11 03
100 04
As you can see, in binary, there will be no numbers greater than 1, except that 0 is 1, but in decimal, there will be no 10, which is from 0 ~ 9.
In our C #, bitwise operations are divided into left displacement and right displacement, which are represented by <and> respectively. The left shift is equivalent to the Left shift, and the right side is supplemented with 0, for example:
10 <1 it means 10 0, and the final result is 100, which is equivalent to 4 in decimal order. At this time, it is difficult to see that the value shifted to 1, which is equivalent to a multiplication of 2, there is also a right shift, for example:
100> 1. The result is 010. It is supplemented with 0 on the left side. After the right shift, it is equivalent to the operation except 2.
With this feature, we can do this when designing the flags feature enumeration with a location.
Let's take a look at its value output.
The result is as follows:
Conclusion: In fact, in decimal, hexadecimal or octal bitwise operations, the calculator converts the bitwise operation to binary, and then calculates the displacement.
Back to directory