<i18n dev> RFR: 8174722: Wrong behavior of DecimalFormat with RoundingMode.UP in special case
Justin Lu
jlu at openjdk.org
Wed May 24 18:39:55 UTC 2023
On Wed, 24 May 2023 17:36:50 GMT, Naoto Sato <naoto at openjdk.org> wrote:
> I just wonder if it is ok to reverse the rounding/truncation only in this special case. If the truncation always comes first, then 0.00 would be correct (then 1.01 may be something wrong). Looks to me that the original comment suggests it tries to truncate those cases. I suggest filing a CSR for further behavioral consideration.
The normal behavior of DecimalFormat (DigitList) "rounds" before truncation. For example, consider
`1.0000009` formatted to `0.0` with `RoundingMode.UP`
DigitList will search past the maximum digits allowed to decide if the formatted value should be rounded. '9' will be found, and as such the value will be "rounded", by incrementing the value by 1 at the max digit location -> `1.1000009`, then DigitList will truncate -> `1.1`
Thus I believe that this change is aligning this special case to be consistent with the existing behavior of rounding before truncation. I will follow-up in the CSR.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14110#issuecomment-1561752907
More information about the i18n-dev
mailing list