: 16 & 0xffff
.
(x & 0x8000) << 1
- , 16- 32- : , 0xffff
, -1 16- , 0xffffffff
, -1 32- . , , .
, ,
(((x & 0xFFFF) << 16) >> 16)
16- "" 32- , .
Note. If you are looking for a binary representation of a String
number, only masking is necessary x & 0xffff
, because the upper 16 bits will still be removed from the result of the string. This Q & A explains how to get a binary representation of an integer with the corresponding number of leading zeros.
source
share