Skip to content

Fix for issues #904 and #2144#2145

Closed
OmarAlJarrah wants to merge 2 commits intogoogle:mainfrom
OmarAlJarrah:master
Closed

Fix for issues #904 and #2144#2145
OmarAlJarrah wants to merge 2 commits intogoogle:mainfrom
OmarAlJarrah:master

Conversation

@OmarAlJarrah
Copy link
Copy Markdown

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
Copy Markdown
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!

}

private static boolean isBigInteger(JsonPrimitive primitive) {
return primitive.value instanceof BigDecimal;
Copy link
Copy Markdown
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
Copy Markdown
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.

@OmarAlJarrah OmarAlJarrah closed this by deleting the head repository May 23, 2025
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