Your algorithm is incorrect, as it returns 0 when asked to compare 1 and 0:
(1 - 0) >>> 32 1 >>> 32 0
In general, I'm not sure that you can compare longs without branching instructions, because the difference in the two lengths might not correspond to the length without overflow, which would change the sign of the difference.
Therefore, I agree with Eugene that using a JDK implementation is probably the best approach.
source share