Update BitMap.mod javadoc

Add thrown exception when divisor is zero. Add link to reference
implementation of Long.remainderUnsigned.

Drop redundant @since tag as it matches the entire class @since.
This commit is contained in:
Alex Herbert 2023-06-13 17:27:28 +01:00
parent 1624bdb89e
commit 5b668d23c6
1 changed files with 9 additions and 4 deletions

View File

@ -115,14 +115,19 @@ public class BitMap {
} }
/** /**
* Performs a modulus calculation on an unsigned long and an positive integer divisor. * Performs a modulus calculation on an unsigned long and a positive integer divisor.
*
* <p>This method computes the same result as {@link Long#remainderUnsigned(long, long)}
* but assumes that the divisor is an integer in the range 1 to 2<sup>31</sup> - 1 inclusive,
* that is a strictly positive integer size.
* *
* <p><em>If the divisor is negative the behavior is not defined.</em></p> * <p><em>If the divisor is negative the behavior is not defined.</em></p>
* *
* @param dividend a unsigned long value to calculate the modulus of. * @param dividend an unsigned long value to calculate the modulus of.
* @param divisor the divisor for the modulus calculation, must be positive. * @param divisor the divisor for the modulus calculation, must be strictly positive.
* @return the remainder or modulus value. * @return the remainder or modulus value.
* @since 4.5 * @throws ArithmeticException if the divisor is zero
* @see Long#remainderUnsigned(long, long)
*/ */
public static int mod(final long dividend, final int divisor) { public static int mod(final long dividend, final int divisor) {
// See Hacker's Delight (2nd ed), section 9.3. // See Hacker's Delight (2nd ed), section 9.3.