8022180: BigInteger Burnikel-Ziegler quotient and remainder calculation assumes quotient parameter is zero
Summary: Clear the quotient in divideAndRemainderBurnikelZiegler() if the divisor is larger than the dividend.
Reviewed-by: alanb, bpb
Contributed-by: Timothy Buktu <tbuktu@hotmail.com>
diff --git a/test/java/math/BigInteger/BigIntegerTest.java b/test/java/math/BigInteger/BigIntegerTest.java
index 47f6af5..279f554 100644
--- a/test/java/math/BigInteger/BigIntegerTest.java
+++ b/test/java/math/BigInteger/BigIntegerTest.java
@@ -74,10 +74,10 @@
static final int ORDER_SMALL = 60;
static final int ORDER_MEDIUM = 100;
- // #bits for testing Karatsuba and Burnikel-Ziegler
+ // #bits for testing Karatsuba
static final int ORDER_KARATSUBA = 1800;
- // #bits for testing Toom-Cook
- static final int ORDER_TOOM_COOK = 3000;
+ // #bits for testing Toom-Cook and Burnikel-Ziegler
+ static final int ORDER_TOOM_COOK = 4000;
// #bits for testing Karatsuba squaring
static final int ORDER_KARATSUBA_SQUARE = 3200;
// #bits for testing Toom-Cook squaring
@@ -964,12 +964,12 @@
nextProbablePrime();
arithmetic(order1); // small numbers
- arithmetic(order3); // Karatsuba / Burnikel-Ziegler range
- arithmetic(order4); // Toom-Cook range
+ arithmetic(order3); // Karatsuba range
+ arithmetic(order4); // Toom-Cook / Burnikel-Ziegler range
divideAndRemainder(order1); // small numbers
- divideAndRemainder(order3); // Karatsuba / Burnikel-Ziegler range
- divideAndRemainder(order4); // Toom-Cook range
+ divideAndRemainder(order3); // Karatsuba range
+ divideAndRemainder(order4); // Toom-Cook / Burnikel-Ziegler range
pow(order1);
pow(order3);
@@ -989,8 +989,8 @@
byteArrayConv(order1);
modInv(order1); // small numbers
- modInv(order3); // Karatsuba / Burnikel-Ziegler range
- modInv(order4); // Toom-Cook range
+ modInv(order3); // Karatsuba range
+ modInv(order4); // Toom-Cook / Burnikel-Ziegler range
modExp(order1, order2);
modExp2(order1);