test/sun/misc/FloatingDecimal/TestFDBigInteger.java
Print this page
rev 7487 : 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
4396272: Parsing doubles fails to follow IEEE for largest decimal that should yield 0
7039391: Use Math.ulp in FloatingDecimal
Summary: Correct rounding and monotonicity problems in floats and doubles
Reviewed-by: martin
Contributed-by: Dmitry Nadezhin <dmitry.nadezhin@oracle.com>, Louis Wasserman <lowasser@google.com>
*** 349,358 ****
--- 349,362 ----
BigInteger biRight = right.toBigInteger();
FDBigInteger diff = left.leftInplaceSub(right);
if (!isImmutable && diff != left) {
throw new Exception("leftInplaceSub of doesn't reuse its argument");
}
+ if (isImmutable) {
+ check(biLeft, left, "leftInplaceSub corrupts its left immutable argument");
+ }
+ check(biRight, right, "leftInplaceSub corrupts its right argument");
check(biLeft.subtract(biRight), diff, "leftInplaceSub returns wrong result");
}
private static void testLeftInplaceSub() throws Exception {
for (int p5 = 0; p5 <= MAX_P5; p5++) {
*** 379,388 ****
--- 383,396 ----
BigInteger biRight = right.toBigInteger();
FDBigInteger diff = left.rightInplaceSub(right);
if (!isImmutable && diff != right) {
throw new Exception("rightInplaceSub of doesn't reuse its argument");
}
+ check(biLeft, left, "leftInplaceSub corrupts its left argument");
+ if (isImmutable) {
+ check(biRight, right, "leftInplaceSub corrupts its right immutable argument");
+ }
try {
check(biLeft.subtract(biRight), diff, "rightInplaceSub returns wrong result");
} catch (Exception e) {
System.out.println(biLeft+" - "+biRight+" = "+biLeft.subtract(biRight));
throw e;