pebble
pebble copied to clipboard
Fix #595 : Numeric operator overflow
Initial pull request that just fixes the comparison operators and could be greatly improved by:
- Merging type specific checks with the already type specific arithmetic operators, applying this fix to all Numeric Binary Expressions.
- More careful consideration of converting numbers of different types, converting the operands to types that can always appropriately handle both numeric values.
Fixes #595
If a maintainer could review everything, I've completed a significant change to the Binary Comparison and Operation methods in OperatorUtils
that should handle all numeric types effectively. When the two operands are of the same class I simplified the type checks.
In all cases, the code only converts a number between types when necessary. For operands of differing types, it converts them to the highest complexity / scale type of the two.
As a bonus, I also added BigInteger support. All unit tests complete successfully, but it may be a good idea to add another unit test similar to the comparison one I have that checks the arithmetic operation logic specifically. 100% code coverage there would not be a bad thing.
Great PR, I'll gladly accept it when test coverage is gonna be better. Can you adjust it ?
Hi @ebussieres , I somehow missed your comments but will review and see if I can find some time to add more test cases.
@thecoden did you get to add more test cases?