Most bitshift solutions I have seen for converting an int to a byte array go like this:
return new byte [] {
(byte) ((i >> 24) & 0xFF),
(byte) ((i >> 16) & 0xFF),
(byte) ((i >> 8) & 0xFF),
(byte) (i & 0xFF);
}
Why the & 0xFF??
& 0xFF
是冗余的,在给定情况下没有区别
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.