-
Notifications
You must be signed in to change notification settings - Fork 226
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
NumberNode's equal definition is impacted by the underlying representation #1378
Comments
We do have an equals method but it just compares the exact string representation of numbers. Comparing across numeric types is going to be... fun. |
Scala actually has this solved, and different representations of numbers can be compared accurately with a lot less edge cases. In particular, Scala libraries tend that need to support several number representations (such as Json libraries) tend to delegate to the |
Attempts to use the most optimal comparisons of number nodes, using .equals if both number values are of the same type, then the string representation of each value, finally followed by comparing the BigDecimal representation of each value using the string cache. If a BigDecimal is needed, it is cached on the number node for future checks. Closes #1378
Attempts to use the most optimal comparisons of number nodes, using .equals if both number values are of the same type, then the string representation of each value, finally followed by comparing the BigDecimal representation of each value using the string cache. If a BigDecimal is needed, it is cached on the number node for future checks. Closes #1378
Attempts to use the most optimal comparisons of number nodes, using .equals if both number values are of the same type, then the string representation of each value, finally followed by comparing the BigDecimal representation of each value using the string cache. If a BigDecimal is needed, it is cached on the number node for future checks. Closes #1378
Attempts to use the most optimal comparisons of number nodes, using .equals if both number values are of the same type, then the string representation of each value, finally followed by comparing the BigDecimal representation of each value using the string cache. If a BigDecimal is needed, it is cached on the number node for future checks. Closes smithy-lang#1378
I'm not sure whether this qualifies as a bug, as it's directly coming from what I'd qualify as a java gotcha, but the two nodes values defined below are not equal with one another :
Node.from(new java.math.BigDecimal("1.0e+10"))
Node.from(1.0e+10)
This makes comparing some models hard. It'd be nice to have the
equals
method of number nodes protect against this gotcha.The text was updated successfully, but these errors were encountered: