+ 5

What does << and >> mean in Java

Java

16th Apr 2017, 11:18 AM
Yonatan Dawit
Yonatan Dawit - avatar
5 Answers
+ 15
Those are bitshift operator's. Imagine an 8 bit integer, I.e 2: 2 in binary is 00000010, 2 >> 1, means shift 2 to the right once, the result is 00000001, which is decimal 1. 2 << 2, means shift 2 to the left twice, the result is 00001000, which is decimal 8
16th Apr 2017, 11:26 AM
Nikolay Nachev
Nikolay Nachev - avatar
+ 10
@Abhishek nope
16th Apr 2017, 12:24 PM
Nikolay Nachev
Nikolay Nachev - avatar
+ 1
they are bitwise bit shift operators
16th Apr 2017, 12:29 PM
IBRAHIM SULE UDI 🇳🇬
IBRAHIM SULE UDI 🇳🇬 - avatar
+ 1
The Java programming language also provides operators that perform bitwise and bit shift operations on integral types. The signed left shift operator << shifts a bit pattern to the left, and the signed right shift operator >> shifts a bit pattern to the right. The bit pattern is given by the left-hand operand, and the number of positions to shift by the right-hand operand. The unsigned right shift operator >>>shifts a zero into the leftmost position, while the leftmost position after >>depends on sign extension.
16th Apr 2017, 12:31 PM
IBRAHIM SULE UDI 🇳🇬
IBRAHIM SULE UDI 🇳🇬 - avatar
0
@Nikolay Nachev ,is the shift circular ?
16th Apr 2017, 12:09 PM
Abhishek