0

what does '>>' operator mean?

Recently on codes of other people I saw >> operator. Couldn't understand it...something like bitwise right or something like that...please tell me what does this operator do?

1st May 2020, 9:28 AM
Gaurav Giri
Gaurav Giri - avatar
2 odpowiedzi
+ 2
well, bitwise operator is used to perform manipulation of data at bit level. if you use right shift it will shift the bits toward right of given number. ex. int a = 6; int b = a >> 2; 4 2 // 6 in bit. 0 0 0 0 1 1 0 //shift 2 bit to the right 1 //result. 0 0 0 0 0 0 1 so b = 1
1st May 2020, 9:43 AM
tres
0
Additionally, you must know that right shift is equivalent to divide (integer division) by 2 raised to the power of numbers of bits and left shift (<<) conversely multiply by 2 power number of bits shifted... As in decimal, removing digit a right divide (integer division) by 10 (power to numbers of digit), and conversely appending 0 digit(s) to the right multiply by 10 (power to numbers of digits): 1234 => 12 <=> 1234 // 100 (10^2) 42 => 4200 <=> 42 * 100
1st May 2020, 10:59 AM
visph
visph - avatar