<i18n dev> RFR: 8159023: Engineering notation of DecimalFormat does not work as documented

Justin Lu jlu at openjdk.org
Sat May 20 00:06:57 UTC 2023

Please review this PR which updates the Scientific Notation section of Decimal Format. It aims to resolve [JDK-8159023](https://bugs.openjdk.org/browse/JDK-8159023) as well as [JDK-6282188](https://bugs.openjdk.org/browse/JDK-6282188).

**Scientific Notation** in Decimal Format contains the definition for a scientific notation formatted number's mantissa as such: _The number of significant digits in the mantissa is the sum of the minimum integer and maximum fraction digits, and is unaffected by the maximum integer digits. For example, 12345 formatted with "##0.##E0" is "12.3E3"._

Both the definition and example are incorrect, as the actual result is "12.E345". 

The following example data show that scientific notation formatted numbers do not adhere to that definition. As, according to the definition, the following numbers should have 3 significant digits, but in reality, they have up to 5.

123 formatted by ##0.#E0 is 123E0
1234 formatted by ##0.#E0 is 1.234E3
12345 formatted by ##0.#E0 is 12.34E3
123456 formatted by ##0.#E0 is 123.5E3
1234567 formatted by ##0.#E0 is 1.235E6
12345678 formatted by ##0.#E0 is 12.35E6
123456789 formatted by ##0.#E0 is 123.5E6 

The actual definition of the mantissa, as well as examples and further context are included in this change. In addition, a test has been added that tests various patterns to numbers and ensures the format follows the new definition's mathematical expression.


Commit messages:
 - Remove comments if they serve no purpose in the code
 - Add test for new definition
 - Add Specification

Changes: https://git.openjdk.org/jdk/pull/14066/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14066&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8159023
  Stats: 158 lines in 2 files changed: 151 ins; 0 del; 7 mod
  Patch: https://git.openjdk.org/jdk/pull/14066.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14066/head:pull/14066

PR: https://git.openjdk.org/jdk/pull/14066

More information about the i18n-dev mailing list