Incorrect %
(modulo) operator behavior for negative divisors
#6609
Labels
bug
Something isn't working
%
(modulo) operator behavior for negative divisors
#6609
Aim
Attempted to create a simple program which does the modulo operation between a positive and a negative number.
The following main.nr:
with Prover.toml:
Outputs
This output is unexpected. It should be
Another example is the following main.nr:
with Prover.toml:
Outputs
In Rust the same program would have the output 20. In some other programming languages the output would be -20
Expected Behavior
Consisted behavior of the modulo operator. Currently the modulo operation between negative constants fails to compile but it has undefined behavior for negative integer parameters.
Bug
The modulo operator produces an incorrect value when working with negative values passed as parameters.
To Reproduce
nargo check
Prover.toml
nargo execute
Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
None
Blocker Context
No response
Nargo Version
nargo version = 0.39.0 noirc version = 0.39.0+45eb7568d56b2d254453b85f236d554232aa5df9 (git version hash: 45eb756, is dirty: false)
NoirJS Version
No response
Proving Backend Tooling & Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: