A
auc
I am attempting to swap big endian bytes to little endian format. Here
is a snippet of code which doesn't seem to work:
byte b[];
public double getDouble (int offset) {
long l = (b[offset+7] & 0xff) + ((b[offset+6] & 0xff) << 8) +
((b[offset+5] & 0xff) << 16) + ((b[offset+4] & 0xff) <<
24) +
((b[offset+3] & 0xff) << 32) + ((b[offset+2] & 0xff) <<
40) +
((b[offset+1] & 0xff) << 48) + (b[offset] << 56);
return Double.longBitsToDouble(l);
}
My class is initialized with an array of bytes and I use the offset to
position within the byte array. I have very similiar code to swap ints,
shorts and floats which works fine. What am I missing with doubles?
Thanks,
Gary V
is a snippet of code which doesn't seem to work:
byte b[];
public double getDouble (int offset) {
long l = (b[offset+7] & 0xff) + ((b[offset+6] & 0xff) << 8) +
((b[offset+5] & 0xff) << 16) + ((b[offset+4] & 0xff) <<
24) +
((b[offset+3] & 0xff) << 32) + ((b[offset+2] & 0xff) <<
40) +
((b[offset+1] & 0xff) << 48) + (b[offset] << 56);
return Double.longBitsToDouble(l);
}
My class is initialized with an array of bytes and I use the offset to
position within the byte array. I have very similiar code to swap ints,
shorts and floats which works fine. What am I missing with doubles?
Thanks,
Gary V