Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6016

Java • Re: Java Help with bitwise operators

$
0
0
-- What is gained by doing this AND?
Nothing really, but it's legitimate as defensive programming practice, or for clarity that one is using an 8-bit entity.
In C, you might do this as "char" may be signed or unsigned, and with signed chars the & 0xFF is needed to remove unwanted sign extension. Thankfully the compiler automatically removes the "& 0xFF" when it can prove that it is pointless.

Statistics: Posted by jahboater — Wed Jul 31, 2024 12:02 pm



Viewing all articles
Browse latest Browse all 6016

Trending Articles