public static int compare ( long serial1 , long serial2 ) { if ( serial1 < 0 || serial1 > MAX32 ) throw new IllegalArgumentException ( serial1 + " out of range" ) ; if ( serial2 < 0 || serial2 > MAX32 ) throw new IllegalArgumentException ( serial2 + " out of range" ) ; long diff = serial1 - serial2 ; if ( diff >= MAX32 ) diff -= ( MAX32 + 1 ) ; else if ( diff < - MAX32 ) diff += ( MAX32 + 1 ) ; return ( int ) diff ; }
Compares two numbers using serial arithmetic . The numbers are assumed to be 32 bit unsigned integers stored in longs .