public static long divideUnsigned ( long dividend , long divisor ) { if ( divisor < 0L ) { // signed comparison // Answer must be 0 or 1 depending on relative magnitude // of dividend and divisor. return ( compareUnsigned ( dividend , divisor ) ) < 0 ? 0L : 1L ; } if ( dividend > 0 ) // Both inputs non-negative return dividend / divisor ; else { /* * For simple code, leveraging BigInteger. Longer and faster * code written directly in terms of operations on longs is * possible; see "Hacker's Delight" for divide and remainder * algorithms. */ return toUnsignedBigInteger ( dividend ) . divide ( toUnsignedBigInteger ( divisor ) ) . longValue ( ) ; } }
Returns the unsigned quotient of dividing the first argument by the second where each argument and the result is interpreted as an unsigned value .