Skip to content

Fix issues handling high-precision numbers#3004

Merged
kstich merged 1 commit intomainfrom
dev/kstich/number-type-fixes
Mar 20, 2026
Merged

Fix issues handling high-precision numbers#3004
kstich merged 1 commit intomainfrom
dev/kstich/number-type-fixes

Conversation

@kstich
Copy link
Copy Markdown
Contributor

@kstich kstich commented Mar 18, 2026

The Double.isFinite method was incorrectly used to detect if a value would fit in a double. The method handles this properly, but it's not actually what we want - we want to know if the value will be accurately represented by a double.

To resolve this, a NumberUtils class is added with a method that validates precision compatibility. Tests are added for this and all call sites to ensure the behavior remains consistent.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@kstich kstich requested a review from a team as a code owner March 18, 2026 21:18
@kstich kstich requested a review from milesziemer March 18, 2026 21:18
@github-actions
Copy link
Copy Markdown
Contributor

This pull request does not contain a staged changelog entry. To create one, use the ./.changes/new-change command. For example:

./.changes/new-change --pull-requests "#3004" --type feature --description "Fix issues handling high-precision numbers"

Make sure that the description is appropriate for a changelog entry and that the proper feature type is used. See ./.changes/README or run ./.changes/new-change -h for more information.

@kstich kstich force-pushed the dev/kstich/number-type-fixes branch 2 times, most recently from 7e2ac5d to 842595d Compare March 18, 2026 21:39
@kstich
Copy link
Copy Markdown
Contributor Author

kstich commented Mar 18, 2026

Need to fix an issue where values over double max/under double min that aren't literal Infinities are translated to infinity when parsed to a Double, but would be valid BigDecimals.

Edit: This is complete

@kstich kstich force-pushed the dev/kstich/number-type-fixes branch from 842595d to cfc979a Compare March 19, 2026 04:17
@kstich kstich requested a review from sugmanue March 19, 2026 04:34
if (doubleValue.isInfinite() || doubleValue.isNaN()) {
// Doubles parse values outside their range, but set their values
// to infinity. See if we got a real infinity or just a big value.
try {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not check the string? Also, can this entire logic block be put into NumberUtils? Otherwise it's being repeated thrice.

@kstich kstich force-pushed the dev/kstich/number-type-fixes branch from cfc979a to 2cfc643 Compare March 19, 2026 18:20
@kstich kstich requested a review from JordonPhillips March 19, 2026 18:20
@kstich kstich force-pushed the dev/kstich/number-type-fixes branch from 2cfc643 to 9bdcfc5 Compare March 19, 2026 18:21
The Double.isFinite method was incorrectly used to detect if a value would
fit in a double. The method handles this properly, but it's not actually what
we want - we want to know if the value will be accurately represented by a
double.

To resolve this, a NumberUtils class is added with a method that validates
precision compatibility. Tests are added for this and all call sites to
ensure the behavior remains consistent.
@kstich kstich force-pushed the dev/kstich/number-type-fixes branch from 9bdcfc5 to 6f80ddb Compare March 19, 2026 19:03
@kstich kstich merged commit 9b6aa2a into main Mar 20, 2026
16 checks passed
@kstich kstich deleted the dev/kstich/number-type-fixes branch March 20, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants