ICU-7609 Allow rounding to negative zero - test case cleanup.
X-SVN-Rev: 28462
This commit is contained in:
parent
8b0fd59d96
commit
93a8105a51
@ -824,8 +824,6 @@ public class DecimalFormat extends NumberFormat {
|
|||||||
// * round(number / roundingDouble, roundingMode, isNegative);
|
// * round(number / roundingDouble, roundingMode, isNegative);
|
||||||
double newNumber = round(number, roundingDouble, roundingDoubleReciprocal, roundingMode,
|
double newNumber = round(number, roundingDouble, roundingDoubleReciprocal, roundingMode,
|
||||||
isNegative);
|
isNegative);
|
||||||
//if (newNumber == 0.0 && number != newNumber)
|
|
||||||
// isNegative = false; // if we touched it, then make zero be zero.
|
|
||||||
number = newNumber;
|
number = newNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2664,16 +2664,16 @@ public class NumberFormatTest extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
df.setRoundingMode(MathContext.ROUND_HALF_UP);
|
df.setRoundingMode(MathContext.ROUND_HALF_UP);
|
||||||
df.setMinimumFractionDigits(1);
|
df.setMinimumFractionDigits(1);
|
||||||
df.setMaximumFractionDigits(1);
|
df.setMaximumFractionDigits(1);
|
||||||
|
String text1 = df.format(-0.01);
|
||||||
System.out.println(df.format(-0.01));
|
|
||||||
//will print -0.0, and the DecimalFormat support
|
|
||||||
//in JDK will result in -0.0 when used with
|
|
||||||
//setRoundingMode(RoundingMode.HALF_UP);
|
|
||||||
|
|
||||||
df.setRoundingIncrement(0.1);
|
df.setRoundingIncrement(0.1);
|
||||||
|
String text2 = df.format(-0.01);
|
||||||
|
|
||||||
System.out.println(df.format(-0.01));
|
// output1 and output2 must be identical
|
||||||
// will print 0.0, but:
|
if (!text1.equals(text2)) {
|
||||||
|
errln("NumberFormat.format() should return the same result - text1="
|
||||||
|
+ text1 + " text2=" + text2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user