On Tue, 6 Apr 2021 20:34:52 GMT, Ian Graves <igra...@openjdk.org> wrote:

> This fixes a bug where the formatting code for `%g` flags incorrectly tries 
> to round `BigDecimal` after determining whether it should be a decimal 
> numeric format or a scientific numeric format. The solution rounds before 
> determining the correct format.

test/jdk/java/util/Formatter/BigDecimalRounding.java line 44:

> 42:     public static void testBigDecimalRounding() {
> 43:         var res1 = String.format("%g", 0.00009999999999999995);
> 44:         var res2 = String.format("%g", 0.00009999999f);

To avoid possible vagaries in decimal -> binary conversion of double values, I 
suggest also testing against a BigDecimal directly rounded to the precision in 
question.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3363

Reply via email to