[英]Converting int to a byte array
Most bitshift solutions I have seen for converting an int to a byte array go like this: 我见过的大多数将int转换为字节数组的位偏移解决方案都是这样的:
return new byte [] {
(byte) ((i >> 24) & 0xFF),
(byte) ((i >> 16) & 0xFF),
(byte) ((i >> 8) & 0xFF),
(byte) (i & 0xFF);
}
Why the & 0xFF?? 为什么是&0xFF?
& 0xFF
是冗余的,在给定情况下没有区别
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.