...
Code Block | ||
---|---|---|
| ||
byte[] b = new byte[] {-1, -1, -1, -1}; int result = 0; for (int i = 0; i < 4; i++) { result = ((result << 8) | (b[i] & 0xff)); } |
Exceptions
NUM01-EX1EX0: Bitwise operations may be used to construct constant expressions. Nevertheless, as a matter of style, we recommend replacing such constant expressions with the equivalent hexadecimal constants 0x1FFFF, in this case.
Code Block | ||
---|---|---|
| ||
int limit = 1 << 17 - 1; // 2^17 - 1 = 131071 |
NUM01-EX2EX1: Data that is normally treated arithmetically may be treated with bitwise operations for the purpose of serialization or deserialization. This is often required for reading or writing the data from a file or network socket. Bitwise operations are also permitted when reading or writing the data from a tightly packed data structure of bytes.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="bec8f20196f6c49f-4cb5b8cb-4bd2499d-ac34b35c-4442b4b933fad00f07fbe956"><ac:plain-text-body><![CDATA[ | [[Steele 1977 | AA. Bibliography#Steele 1977]] | ]]></ac:plain-text-body></ac:structured-macro> |
...