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

Fix for issues #904 and #2144 #2145

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

OmarAlJarrah
Copy link

As a BigDecimal is essentially a wrapper around a BigInteger that "remembers where the decimal point is", casting BigInteger to BigDecimal using the provided constructor (or the method that uses the constructor in the conversion process), and do the comparing process makes more sense, avoiding the bug of max long/double values comparison.

Copy link
Member

@eamonnmcmanus eamonnmcmanus left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this!

@@ -292,4 +298,16 @@ private static boolean isIntegral(JsonPrimitive primitive) {
}
return false;
}

private static boolean isBigInteger(JsonPrimitive primitive) {
return primitive.value instanceof BigDecimal;
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be BigInteger? Which in turn makes me think that there should be a test that would have caught this.

Speaking of tests, in general if you are proposing a fix for an issue, you should include a test that fails without the fix and passes with it.

Copy link
Author

Choose a reason for hiding this comment

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

@eamonnmcmanus
Yes that should be a BigInteger, as for the testing part, thank you for the tip, I will make sure to provide tests with any future commits.

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