bug: Saturation Arithmetic is incorrect with negative signed integers
bengineer42 opened this issue · 0 comments
bengineer42 commented
Bug Report
Cairo version:
2.8.4
Current behavior:
let a: i8 = 127;
let b: i8 = -127;
let c = a.saturating_sub(b);
would give -128
Expected behavior:
Above should give 127
Steps to reproduce:
Above using the SaturatingSub
Trait
Related code:
https://github.com/starkware-libs/cairo/blob/main/corelib/src/num/traits/ops/saturating.cairo#L22-L58
https://github.com/starkware-libs/cairo/blob/main/corelib/src/integer.cairo#L2965-L2988
Other information: