Skip to content
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

bug: Saturation Arithmetic is incorrect with negative signed integers #6462

Closed
bengineer42 opened this issue Oct 7, 2024 · 0 comments · Fixed by #6465 · May be fixed by #6463
Closed

bug: Saturation Arithmetic is incorrect with negative signed integers #6462

bengineer42 opened this issue Oct 7, 2024 · 0 comments · Fixed by #6465 · May be fixed by #6463
Labels
bug Something isn't working

Comments

@bengineer42
Copy link

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:

@bengineer42 bengineer42 added the bug Something isn't working label Oct 7, 2024
orizi added a commit that referenced this issue Oct 7, 2024
Fixing issue with returning the proper saturating value on
`Saturating{Add,Sub}`.

Fixing #6462.

commit-id:861630ee
orizi added a commit that referenced this issue Oct 7, 2024
Fixing issue with returning the proper saturating value on
`Saturating{Add,Sub}`.

Fixing #6462.

commit-id:861630ee
orizi added a commit that referenced this issue Oct 7, 2024
Fixing issue with returning the proper saturating value on
`Saturating{Add,Sub}`.

Fixing #6462.

commit-id:861630ee
orizi added a commit that referenced this issue Oct 8, 2024
Fixing issue with returning the proper saturating value on
`Saturating{Add,Sub}`.

Fixing #6462.

commit-id:861630ee
orizi added a commit that referenced this issue Oct 10, 2024
Fixing issue with returning the proper saturating value on
`Saturating{Add,Sub}`.

Fixing #6462.

commit-id:861630ee
orizi added a commit that referenced this issue Oct 10, 2024
Fixing issue with returning the proper saturating value on
`Saturating{Add,Sub}`.

Fixing #6462.

commit-id:861630ee
orizi added a commit that referenced this issue Oct 10, 2024
Fixing issue with returning the proper saturating value on
`Saturating{Add,Sub}`.

Fixing #6462.

commit-id:861630ee
orizi added a commit that referenced this issue Oct 10, 2024
Fixing issue with returning the proper saturating value on
`Saturating{Add,Sub}`.

Fixing #6462.

commit-id:861630ee
@orizi orizi closed this as completed Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants