pebble icon indicating copy to clipboard operation
pebble copied to clipboard

Fix #595 : Numeric operator overflow

Open codesplode opened this issue 3 years ago • 4 comments

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

codesplode avatar Jun 16 '21 15:06 codesplode

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.

codesplode avatar Jun 17 '21 17:06 codesplode

Great PR, I'll gladly accept it when test coverage is gonna be better. Can you adjust it ?

ebussieres avatar Oct 28 '22 15:10 ebussieres

Hi @ebussieres , I somehow missed your comments but will review and see if I can find some time to add more test cases.

thecoden avatar Dec 03 '22 23:12 thecoden

@thecoden did you get to add more test cases?

ArneBab avatar May 24 '24 13:05 ArneBab