Saturday, November 29, 2008

java.io.bits

Thia class defines the static operations to convert a element at byte array to corresponding java basic type value and push a java basic type value into a specified position in the byte array.

There are some things you need to care about

1. the index of the array is from [0--n-1] just same as c/c++

2. the coding is using big endian byte order, that is, the content in lower address is more important.

3. This is a question mark.. as the following code sample:
static short getShort(byte[] b, int off) {
return (short) (((b[off + 1] & 0xFF) << 0) +
((b[off + 0]) << 8));
}
why it needs bit and with 0xFF.???..

4.bit operations <<, >> are sign shift
bit operations <<<, >>> are unsigned shift

No comments: