// strip the sign bit, a modififed form of abs that never returns a negative number. final long n = someValue(); final long p = n & 0x7fffffffffffffffL; // or easier to proofread final long p = n & (-1L >>> 1); // takes two cycles, but simple to understand final long p = (n << 1) >>> 1; // or more simply final long p = n & Long.MAX_VALUE;