Some bitwise operations in groovy shell, better install this shell via gvm.
$ groovysh
groovy:000> bb = 205
===> 205
groovy:000> cc = -51
===> -51
groovy:000> Integer.toBinaryString(bb)
===> 11001101
groovy:000> Integer.toBinaryString(cc)
===> 11111111111111111111111111001101
groovy:000> Integer.toBinaryString(cc >> 2)
===> 11111111111111111111111111110011
groovy:000> Integer.toBinaryString(cc >>> 2)
===> 111111111111111111111111110011
groovy:000> bb == (cc & 0xFF)
===> true
So Java use 4 bytes to represent a integer. The left-most bit is "1" when the integer is a negative, otherwise the position is "0". The "var & 0xFF" converts the first 3 bytes to 0. In other words, this method converts var into 0~255.
Conversion between binary string and integer and bytes.
groovy:000> aa = 45
===> 45
groovy:000> aas = Integer.toBinaryString(aa)
===> 101101
groovy:000> aa == Byte.parseByte(aas, 2)
===> true
groovy:000> aa.getClass()
===> class java.lang.Integer
groovy:000> aas.getClass()
===> class java.lang.String