noir
noir copied to clipboard
Operator `>>` does arithmetic or logical shift, depending on rhs
Aim
Attempted to create a simple program which right-shifts a number.
The following main.nr:
fn main(a: i16) {
println(a >> 3);
}
with Prover.toml:
a = "-769"
Results with an arithmetic >>, outputing -96.
However, the following main.nr:
fn main(a: i16, b: u8) {
println(a >> b);
}
with Prover.toml:
a = "-769"
b = 3
Results with a logical >>, outputting 8095.
Expected Behavior
>> to act consistently on the same value
Bug
>> with a constant right hand-side behaves as an arithmetic shift, while with an input value rhs it behaves as a logical shift
To Reproduce
- Create two
Noirprojects, for each pair of program andProver.toml - Run them with
nargo execute - Observe the different output
Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
Nice-to-have
Blocker Context
No response
Nargo Version
nargo version = 0.34.0 noirc version = 0.34.0+94ed0b8fb13a923a59f6f3ccd8d7c75e191deeca (git version hash: 94ed0b8fb13a923a59f6f3ccd8d7c75e191deeca, 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