문제

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 is redundant and makes no difference in the given case

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top