Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = x >> 1;
- x = x / 2;
- -5 / 2 = -2
- -5 >> 1 = -3
- x = x / 2 + 5;
- x = x >> 1 + 5; // not the same as above
- int div2signed(int a) {
- return a / 2;
- }
- movl %edi, %eax
- shrl $31, %eax
- addl %edi, %eax
- sarl %eax
- ret
- int shr2signed(int a) {
- return a >> 1;
- }
- sarl %edi
- movl %edi, %eax
- ret
- q = i >> n; is the same as: q = i / 2**n;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement