+ 3

someome who know what & 0xff do in the example bellow

if someone can explain what that & in the second instruction means : byte [] buffer=new bite[4]; int blue=(buffer[0]& 0xff);

3rd Feb 2020, 8:56 PM
Badreddine_FX
Badreddine_FX - avatar
4 Answers
+ 3
thanks to you all👌
3rd Feb 2020, 9:45 PM
Badreddine_FX
Badreddine_FX - avatar
+ 1
& is bitwise AND operator. 0xff is hexadecimal number (of 255)with all 1's buffer[0] value is bitwise AND operatored with 11111111 See here for more.. https://www.sololearn.com/learn/4072/?ref=app
3rd Feb 2020, 9:06 PM
Jayakrishna 🇼🇳
+ 1
& is a bitwise operator You can look here: https://www.sololearn.com/learn/4072/?ref=app 0xff is a hexadecimal value (= 255 in decimal) for example: buffer[0] would be 3 00000011 (3) & 11111111 (255) = 00000011 = 3 int blue would be 3. But it gives you only the value for blue. A color needs values for red, green and blue (RGB). Where did you see this code? Using class Color or class PixelWriter/PixelReader?
3rd Feb 2020, 9:22 PM
Denise Roßberg
Denise Roßberg - avatar