Could someone give me a brief explanation about the results of these operations?
System.out.println(1<<4);
System.out.println(1>>4);
System.out.println(5>>2);
16
0
1
Here I leave link where I tried them.
They are bit-level operators
<< desplazamiento a la izquierda, rellenando con ceros a la derecha
>> desplazamiento a la derecha, rellenando con el bit de signo por la izquierda
Perform the manipulation of the bits of the data with which they operate. The data must be of the integer type.
1
'>>': desplazamiento a la derecha de los bits del operando
'<<': desplazamiento a la izquierda de los bits de operando
< < "Offset to the left"
We wish to run number 33 two positions to the left. Then we made:
int j = 33;
int k = j << 2;
This is the result:
00000000000000000000000000100001 : j = 33
00000000000000000000000010000100 : k = 33 << 2 ; k = 132
Each "hole" that is on the right after running this number is filled with zeros. The bits on the left are lost, it is not a rotation operation. If we pay attention, we will observe that this operation multiplied to j by 2 so many times as positions have been displaced. In this case it multiplied by 4 (2 x 2). Note that the number sign may change after the operation (for example 1