How can I convert two 32 bit integers (int
) to one 64 bit long
and vice versa?
long c = (long)a << 32 | b & 0xFFFFFFFFL;
int aBack = (int)(c >> 32);
int bBack = (int)c;
In Java, you don't need quite so many parentheses, or any masking on the reverse calculation.