Encode two ints into one long
Java
Hard
7 views
Problem Description
Task: pack two 32-bit ints (a,b) into one long and unpack later.
Output Format
Return value
Constraints
Keep sign bits correct.
Official Solution
static long pack(int a,int b){return ((long)a<<32) ^ (b & 0xffffffffL);}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!