/** *TestFloorDivandthenFloorModwithintdata.
*/ staticvoid testIntFloorDivMod(int x, int y, Object divExpected, Object modExpected) {
testIntFloorDiv(x, y, divExpected);
testIntFloorMod(x, y, modExpected);
}
/** *TestFloorDivwithintdata.
*/ staticvoid testIntFloorDiv(int x, int y, Object expected) {
Object result = doFloorDiv(x, y); if (!resultEquals(result, expected)) {
fail("FAIL: Math.floorDiv(%d, %d) = %s; expected %s%n", x, y, result, expected);
}
try { // Verify result against double precision floor function int tmp = x / y; // Force ArithmeticException for divide by zero double ff = x - Math.floor((double)x / (double)y) * y; int fr = (int)ff; boolean t = (fr == ((Integer)result)); if (!result.equals(fr)) {
fail("FAIL: Math.floorMod(%d, %d) = %s differs from Math.floor(x, y): %d%n", x, y, result, fr);
}
} catch (ArithmeticException ae) { if (y != 0) {
fail("FAIL: Math.floorMod(%d, %d); unexpected %s%n", x, y, ae);
}
}
}
/** *TestthelongfloorDivandfloorModmethods. *MathandStrictMatharetestedandthesameresultsareexpectedforboth.
*/ staticvoid testLongFloorDivMod(long x, long y, Object divExpected, Object modExpected) {
testLongFloorDiv(x, y, divExpected);
testLongFloorMod(x, y, modExpected);
}
/** *TestFloorDivwithlongargumentsagainstexpectedvalue. *TheexpectedvalueisusuallyaLongbutinsomecasesis *anArithmeticException. * *@paramxdividend *@paramymodulus *@paramexpectedexpectedvalue,
*/ staticvoid testLongFloorDiv(long x, long y, Object expected) {
Object result = doFloorDiv(x, y); if (!resultEquals(result, expected)) {
fail("FAIL: long Math.floorDiv(%d, %d) = %s; expected %s%n", x, y, result, expected);
}
Object strict_result = doStrictFloorDiv(x, y); if (!resultEquals(strict_result, expected)) {
fail("FAIL: long StrictMath.floorDiv(%d, %d) = %s; expected %s%n", x, y, strict_result, expected);
}
}
/** *TestFloorModoflongargumentsagainstexpectedvalue. *TheexpectedvalueisusuallyaLongbutinsomecasesis *anArithmeticException. * *@paramxdividend *@paramymodulus *@paramexpectedexpectedvalue
*/ staticvoid testLongFloorMod(long x, long y, Object expected) {
Object result = doFloorMod(x, y); if (!resultEquals(result, expected)) {
fail("FAIL: long Math.floorMod(%d, %d) = %s; expected %s%n", x, y, result, expected);
}
Object strict_result = doStrictFloorMod(x, y); if (!resultEquals(strict_result, expected)) {
fail("FAIL: long StrictMath.floorMod(%d, %d) = %s; expected %s%n", x, y, strict_result, expected);
}
try { // Verify the result against BigDecimal rounding mode.
BigDecimal xD = new BigDecimal(x);
BigDecimal yD = new BigDecimal(y);
BigDecimal resultD = xD.divide(yD, RoundingMode.FLOOR);
resultD = resultD.multiply(yD);
resultD = xD.subtract(resultD); long fr = resultD.longValue(); if (!result.equals(fr)) {
fail("FAIL: Long.floorMod(%d, %d) = %d is different than BigDecimal result: %d%n", x, y, result, fr);
}
} catch (ArithmeticException ae) { if (y != 0) {
fail("FAIL: long Math.floorMod(%d, %d); unexpected ArithmeticException from bigdecimal");
}
}
}
/** *TesttheintegerfloorDivandfloorModmethods. *MathandStrictMatharetestedandthesameresultsareexpectedforboth.
*/ staticvoid testLongIntFloorDivMod(long x, int y, Object divExpected, Object modExpected) {
testLongIntFloorDiv(x, y, divExpected);
testLongIntFloorMod(x, y, modExpected);
}
/** *TestFloorDivwithlongargumentsagainstexpectedvalue. *TheexpectedvalueisusuallyaLongbutinsomecasesis *anArithmeticException. * *@paramxdividend *@paramymodulus *@paramexpectedexpectedvalue,
*/ staticvoid testLongIntFloorDiv(long x, int y, Object expected) {
Object result = doFloorDiv(x, y); if (!resultEquals(result, expected)) {
fail("FAIL: long Math.floorDiv(%d, %d) = %s; expected %s%n", x, y, result, expected);
}
Object strict_result = doStrictFloorDiv(x, y); if (!resultEquals(strict_result, expected)) {
fail("FAIL: long StrictMath.floorDiv(%d, %d) = %s; expected %s%n", x, y, strict_result, expected);
}
}
/** *TestFloorModoflongargumentsagainstexpectedvalue. *TheexpectedvalueisusuallyaLongbutinsomecasesis *anArithmeticException. * *@paramxdividend *@paramymodulus *@paramexpectedexpectedvalue
*/ staticvoid testLongIntFloorMod(long x, int y, Object expected) {
Object result = doFloorMod(x, y); if (!resultEquals(result, expected)) {
fail("FAIL: int Math.floorMod(%d, %d) = %s; expected %s%n", x, y, result, expected);
}
Object strict_result = doStrictFloorMod(x, y); if (!resultEquals(strict_result, expected)) {
fail("FAIL: int StrictMath.floorMod(%d, %d) = %s; expected %s%n", x, y, strict_result, expected);
}
try { // Verify the result against BigDecimal rounding mode.
BigDecimal xD = new BigDecimal(x);
BigDecimal yD = new BigDecimal(y);
BigDecimal resultD = xD.divide(yD, RoundingMode.FLOOR);
resultD = resultD.multiply(yD);
resultD = xD.subtract(resultD); int fr = resultD.intValue(); if (!result.equals(fr)) {
fail("FAIL: Long.floorMod(%d, %d) = %d is different than BigDecimal result: %d%n", x, y, result, fr);
}
} catch (ArithmeticException ae) { if (y != 0) {
fail("FAIL: long Math.floorMod(%d, %d); unexpected ArithmeticException from bigdecimal");
}
}
}
/** *TestCeilDivandthenCeilModwithintdata.
*/ staticvoid testIntCeilDivMod(int x, int y, Object divExpected, Object modExpected) {
testIntCeilDiv(x, y, divExpected);
testIntCeilMod(x, y, modExpected);
}
/** *TestCeilDivwithintdata.
*/ staticvoid testIntCeilDiv(int x, int y, Object expected) {
Object result = doCeilDiv(x, y); if (!resultEquals(result, expected)) {
fail("FAIL: Math.ceilDiv(%d, %d) = %s; expected %s%n", x, y, result, expected);
}
try { // Verify result against double precision ceil function int tmp = x / y; // Force ArithmeticException for divide by zero double ff = x - Math.ceil((double)x / (double)y) * y; int fr = (int)ff; boolean t = (fr == ((Integer)result)); if (!result.equals(fr)) {
fail("FAIL: Math.ceilMod(%d, %d) = %s differs from Math.ceil(x, y): %d%n", x, y, result, fr);
}
} catch (ArithmeticException ae) { if (y != 0) {
fail("FAIL: Math.ceilMod(%d, %d); unexpected %s%n", x, y, ae);
}
}
}
/** *TestthelongceilDivandceilModmethods. *MathandStrictMatharetestedandthesameresultsareexpectedforboth.
*/ staticvoid testLongCeilDivMod(long x, long y, Object divExpected, Object modExpected) {
testLongCeilDiv(x, y, divExpected);
testLongCeilMod(x, y, modExpected);
}
/** *TestCeilDivwithlongargumentsagainstexpectedvalue. *TheexpectedvalueisusuallyaLongbutinsomecasesis *anArithmeticException. * *@paramxdividend *@paramymodulus *@paramexpectedexpectedvalue,
*/ staticvoid testLongCeilDiv(long x, long y, Object expected) {
Object result = doCeilDiv(x, y); if (!resultEquals(result, expected)) {
fail("FAIL: long Math.ceilDiv(%d, %d) = %s; expected %s%n", x, y, result, expected);
}
Object strict_result = doStrictCeilDiv(x, y); if (!resultEquals(strict_result, expected)) {
fail("FAIL: long StrictMath.ceilDiv(%d, %d) = %s; expected %s%n", x, y, strict_result, expected);
}
}
/** *TestCeilModoflongargumentsagainstexpectedvalue. *TheexpectedvalueisusuallyaLongbutinsomecasesis *anArithmeticException. * *@paramxdividend *@paramymodulus *@paramexpectedexpectedvalue
*/ staticvoid testLongCeilMod(long x, long y, Object expected) {
Object result = doCeilMod(x, y); if (!resultEquals(result, expected)) {
fail("FAIL: long Math.ceilMod(%d, %d) = %s; expected %s%n", x, y, result, expected);
}
Object strict_result = doStrictCeilMod(x, y); if (!resultEquals(strict_result, expected)) {
fail("FAIL: long StrictMath.ceilMod(%d, %d) = %s; expected %s%n", x, y, strict_result, expected);
}
try { // Verify the result against BigDecimal rounding mode.
BigDecimal xD = new BigDecimal(x);
BigDecimal yD = new BigDecimal(y);
BigDecimal resultD = xD.divide(yD, RoundingMode.CEILING);
resultD = resultD.multiply(yD);
resultD = xD.subtract(resultD); long fr = resultD.longValue(); if (!result.equals(fr)) {
fail("FAIL: Long.ceilMod(%d, %d) = %d is different than BigDecimal result: %d%n", x, y, result, fr);
}
} catch (ArithmeticException ae) { if (y != 0) {
fail("FAIL: long Math.ceilMod(%d, %d); unexpected ArithmeticException from bigdecimal");
}
}
}
/** *TesttheintegerceilDivandceilModmethods. *MathandStrictMatharetestedandthesameresultsareexpectedforboth.
*/ staticvoid testLongIntCeilDivMod(long x, int y, Object divExpected, Object modExpected) {
testLongIntCeilDiv(x, y, divExpected);
testLongIntCeilMod(x, y, modExpected);
}
/** *TestCeilDivwithlongargumentsagainstexpectedvalue. *TheexpectedvalueisusuallyaLongbutinsomecasesis *anArithmeticException. * *@paramxdividend *@paramymodulus *@paramexpectedexpectedvalue,
*/ staticvoid testLongIntCeilDiv(long x, int y, Object expected) {
Object result = doCeilDiv(x, y); if (!resultEquals(result, expected)) {
fail("FAIL: long Math.ceilDiv(%d, %d) = %s; expected %s%n", x, y, result, expected);
}
Object strict_result = doStrictCeilDiv(x, y); if (!resultEquals(strict_result, expected)) {
fail("FAIL: long StrictMath.ceilDiv(%d, %d) = %s; expected %s%n", x, y, strict_result, expected);
}
}
/** *TestCeilModoflongargumentsagainstexpectedvalue. *TheexpectedvalueisusuallyaLongbutinsomecasesis *anArithmeticException. * *@paramxdividend *@paramymodulus *@paramexpectedexpectedvalue
*/ staticvoid testLongIntCeilMod(long x, int y, Object expected) {
Object result = doCeilMod(x, y); if (!resultEquals(result, expected)) {
fail("FAIL: int Math.ceilMod(%d, %d) = %s; expected %s%n", x, y, result, expected);
}
Object strict_result = doStrictCeilMod(x, y); if (!resultEquals(strict_result, expected)) {
fail("FAIL: int StrictMath.ceilMod(%d, %d) = %s; expected %s%n", x, y, strict_result, expected);
}
try { // Verify the result against BigDecimal rounding mode.
BigDecimal xD = new BigDecimal(x);
BigDecimal yD = new BigDecimal(y);
BigDecimal resultD = xD.divide(yD, RoundingMode.CEILING);
resultD = resultD.multiply(yD);
resultD = xD.subtract(resultD); int fr = resultD.intValue(); if (!result.equals(fr)) {
fail("FAIL: Long.ceilMod(%d, %d) = %d is different than BigDecimal result: %d%n", x, y, result, fr);
}
} catch (ArithmeticException ae) { if (y != 0) {
fail("FAIL: long Math.ceilMod(%d, %d); unexpected ArithmeticException from bigdecimal");
}
}
}
if (result.equals(expected)) { returntrue;
} // Handle special case to compare ArithmeticExceptions if (result instanceof ArithmeticException && expected instanceof ArithmeticException) { returntrue;
} returnfalse;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.28 Sekunden
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.