On Fri, 3 May 2024 08:47:03 GMT, Justin Lu <j...@openjdk.org> wrote: > Please review this PR which corrects an edge case bug for > java.text.DecimalFormat that causes incorrect parsing results for strings > with very large exponent values. > > When parsing values with large exponents, if the value of the exponent > exceeds `Integer.MAX_VALUE`, the parsed value is equal to 0. If the value of > the exponent exceeds `Long.MAX_VALUE`, the parsed value is equal to the > mantissa. Both results are confusing and incorrect. > > For example, > > > NumberFormat fmt = NumberFormat.getInstance(Locale.US); > fmt.parse(".1E2147483648"); // returns 0.0 > fmt.parse(".1E9223372036854775808"); // returns 0.1 > // For comparison > Double.parseDouble(".1E2147483648"); // returns Infinity > Double.parseDouble(".1E9223372036854775808"); // returns Infinity > > > After this change, both parse calls return `Double.POSITIVE_INFINITY` now.
This pull request has now been integrated. Changeset: ffb0867e Author: Justin Lu <j...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/ffb0867e2c07b41cb7124e11fe6cf63d9471f0d2 Stats: 269 lines in 4 files changed: 254 ins; 2 del; 13 mod 8331485: Odd Results when Parsing Scientific Notation with Large Exponent 8331680: NumberFormat is missing some bad exponent strict parse cases Reviewed-by: naoto ------------- PR: https://git.openjdk.org/jdk/pull/19075