Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はこれを持っていますbyte/ int 0001 0010(18)。byteこれを/intに分割する必要があります
byte
int
0001 0010
18
0001 0000(16)および 0000 0010(2)。
0001 0000
16
0000 0010
2
Javaでそれを行うにはどうすればよいですか?
&はビットごとの AND です。-16は11110000バイナリで、15です00001111。
&
-16
11110000
15
00001111
public static byte[] split(byte input) { byte[] output = new byte[2]; output[0] = (byte) (input & -16); output[1] = (byte) (input & 15); return output; }