## test/sun/misc/FloatingDecimal/TestFDBigInteger.java

```rev 7487 : 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
 ``` `````` 334 check(bt.multiply(biPow52(p5, p2)), r, "multByPow52 returns wrong result"); 335 } 336 337 private static void testMultByPow52() throws Exception { 338 for (int p5 = 0; p5 <= MAX_P5; p5++) { 339 for (int p2 = 0; p2 <= MAX_P2; p2++) { 340 // This strange way of creating a value ensures that it is mutable. 341 FDBigInteger value = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2); 342 testMultByPow52(value, p5, p2); 343 } 344 } 345 } 346 347 private static void testLeftInplaceSub(FDBigInteger left, FDBigInteger right, boolean isImmutable) throws Exception { 348 BigInteger biLeft = left.toBigInteger(); 349 BigInteger biRight = right.toBigInteger(); 350 FDBigInteger diff = left.leftInplaceSub(right); 351 if (!isImmutable && diff != left) { 352 throw new Exception("leftInplaceSub of doesn't reuse its argument"); 353 } 354 check(biLeft.subtract(biRight), diff, "leftInplaceSub returns wrong result"); 355 } 356 357 private static void testLeftInplaceSub() throws Exception { 358 for (int p5 = 0; p5 <= MAX_P5; p5++) { 359 for (int p2 = 0; p2 <= MAX_P2; p2++) { 360 // for (int p5r = 0; p5r <= p5; p5r += 10) { 361 // for (int p2r = 0; p2r <= p2; p2r += 10) { 362 for (int p5r = 0; p5r <= p5; p5r++) { 363 for (int p2r = 0; p2r <= p2; p2r++) { 364 // This strange way of creating a value ensures that it is mutable. 365 FDBigInteger left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2); 366 FDBigInteger right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r); 367 testLeftInplaceSub(left, right, false); 368 left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2); 369 left.makeImmutable(); 370 testLeftInplaceSub(left, right, true); 371 } 372 } 373 } 374 } 375 } 376 377 private static void testRightInplaceSub(FDBigInteger left, FDBigInteger right, boolean isImmutable) throws Exception { 378 BigInteger biLeft = left.toBigInteger(); 379 BigInteger biRight = right.toBigInteger(); 380 FDBigInteger diff = left.rightInplaceSub(right); 381 if (!isImmutable && diff != right) { 382 throw new Exception("rightInplaceSub of doesn't reuse its argument"); 383 } 384 try { 385 check(biLeft.subtract(biRight), diff, "rightInplaceSub returns wrong result"); 386 } catch (Exception e) { 387 System.out.println(biLeft+" - "+biRight+" = "+biLeft.subtract(biRight)); 388 throw e; 389 } 390 } 391 392 private static void testRightInplaceSub() throws Exception { 393 for (int p5 = 0; p5 <= MAX_P5; p5++) { 394 for (int p2 = 0; p2 <= MAX_P2; p2++) { 395 // for (int p5r = 0; p5r <= p5; p5r += 10) { 396 // for (int p2r = 0; p2r <= p2; p2r += 10) { 397 for (int p5r = 0; p5r <= p5; p5r++) { 398 for (int p2r = 0; p2r <= p2; p2r++) { 399 // This strange way of creating a value ensures that it is mutable. 400 FDBigInteger left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2); 401 FDBigInteger right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r); 402 testRightInplaceSub(left, right, false); 403 right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r); ``` ``` `````` 334 check(bt.multiply(biPow52(p5, p2)), r, "multByPow52 returns wrong result"); 335 } 336 337 private static void testMultByPow52() throws Exception { 338 for (int p5 = 0; p5 <= MAX_P5; p5++) { 339 for (int p2 = 0; p2 <= MAX_P2; p2++) { 340 // This strange way of creating a value ensures that it is mutable. 341 FDBigInteger value = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2); 342 testMultByPow52(value, p5, p2); 343 } 344 } 345 } 346 347 private static void testLeftInplaceSub(FDBigInteger left, FDBigInteger right, boolean isImmutable) throws Exception { 348 BigInteger biLeft = left.toBigInteger(); 349 BigInteger biRight = right.toBigInteger(); 350 FDBigInteger diff = left.leftInplaceSub(right); 351 if (!isImmutable && diff != left) { 352 throw new Exception("leftInplaceSub of doesn't reuse its argument"); 353 } 354 if (isImmutable) { 355 check(biLeft, left, "leftInplaceSub corrupts its left immutable argument"); 356 } 357 check(biRight, right, "leftInplaceSub corrupts its right argument"); 358 check(biLeft.subtract(biRight), diff, "leftInplaceSub returns wrong result"); 359 } 360 361 private static void testLeftInplaceSub() throws Exception { 362 for (int p5 = 0; p5 <= MAX_P5; p5++) { 363 for (int p2 = 0; p2 <= MAX_P2; p2++) { 364 // for (int p5r = 0; p5r <= p5; p5r += 10) { 365 // for (int p2r = 0; p2r <= p2; p2r += 10) { 366 for (int p5r = 0; p5r <= p5; p5r++) { 367 for (int p2r = 0; p2r <= p2; p2r++) { 368 // This strange way of creating a value ensures that it is mutable. 369 FDBigInteger left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2); 370 FDBigInteger right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r); 371 testLeftInplaceSub(left, right, false); 372 left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2); 373 left.makeImmutable(); 374 testLeftInplaceSub(left, right, true); 375 } 376 } 377 } 378 } 379 } 380 381 private static void testRightInplaceSub(FDBigInteger left, FDBigInteger right, boolean isImmutable) throws Exception { 382 BigInteger biLeft = left.toBigInteger(); 383 BigInteger biRight = right.toBigInteger(); 384 FDBigInteger diff = left.rightInplaceSub(right); 385 if (!isImmutable && diff != right) { 386 throw new Exception("rightInplaceSub of doesn't reuse its argument"); 387 } 388 check(biLeft, left, "leftInplaceSub corrupts its left argument"); 389 if (isImmutable) { 390 check(biRight, right, "leftInplaceSub corrupts its right immutable argument"); 391 } 392 try { 393 check(biLeft.subtract(biRight), diff, "rightInplaceSub returns wrong result"); 394 } catch (Exception e) { 395 System.out.println(biLeft+" - "+biRight+" = "+biLeft.subtract(biRight)); 396 throw e; 397 } 398 } 399 400 private static void testRightInplaceSub() throws Exception { 401 for (int p5 = 0; p5 <= MAX_P5; p5++) { 402 for (int p2 = 0; p2 <= MAX_P2; p2++) { 403 // for (int p5r = 0; p5r <= p5; p5r += 10) { 404 // for (int p2r = 0; p2r <= p2; p2r += 10) { 405 for (int p5r = 0; p5r <= p5; p5r++) { 406 for (int p2r = 0; p2r <= p2; p2r++) { 407 // This strange way of creating a value ensures that it is mutable. 408 FDBigInteger left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2); 409 FDBigInteger right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r); 410 testRightInplaceSub(left, right, false); 411 right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r); ```