Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve NumberNode #1965

Merged
merged 1 commit into from
Sep 5, 2023
Merged

Improve NumberNode #1965

merged 1 commit into from
Sep 5, 2023

Conversation

mtdowling
Copy link
Member

@mtdowling mtdowling commented Sep 1, 2023

This change now makes the BigDecimal get created eagerly, and accounts
for NaN and Infinity. The previous implementation would have failed
in these cases. NodeValidationVisitor now uses the computed BigDecimal
rather than create a one-off each time. It also doesn't recreate the
already available BigDecimcal of the range trait.

This change deprecates isNaturalNumber since that method was poorly
named. A natural number is an integer >= 1, but we were including 0
(which is likely why some callers assumed it asserts >= 0).

This also adds an isNegative method since multiple callers need to
assert that a NumberNode contains a non-negative value.

@mtdowling mtdowling requested a review from a team as a code owner September 1, 2023 20:49
@mtdowling mtdowling changed the title Improve number normalization in NumberNode Improve NumberNode Sep 2, 2023
This change now makes the BigDecimal get created eagerly, and accounts
for NaN and Infinity. The previous implementation would have failed
in these cases. NodeValidationVisitor now uses the computed BigDecimal
rather than create a one-off each time. It also doesn't recreate the
already available BigDecimcal of the range trait.

This change deprecates isNaturalNumber since that method was poorly
named. A natural number is an integer >= 1, but we were including 0
(which is likely why some callers assumed it asserts >= 0).

This also adds an isNegative method since multiple callers need to
assert that a NumberNode contains a non-negative value.
@mtdowling mtdowling merged commit 6e7cc38 into main Sep 5, 2023
@kstich kstich deleted the improve-number-node branch September 6, 2023 15:50
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.

2 participants