answersLogoWhite

0

Nothing special: value >> number.

Example:

/* shift.c */

#include <stdio.h>

int main (void)

{

long n;

int i;

n= -98765;

for (i=0; i<20; ++i) {

printf ("%2d: %6ld %lx\n", i, n>>i, n>>i);

}

return 0;

}

output:

0: -98765 fffe7e33

1: -49383 ffff3f19

2: -24692 ffff9f8c

3: -12346 ffffcfc6

4: -6173 ffffe7e3

5: -3087 fffff3f1

6: -1544 fffff9f8

7: -772 fffffcfc

8: -386 fffffe7e

9: -193 ffffff3f

10: -97 ffffff9f

11: -49 ffffffcf

12: -25 ffffffe7

13: -13 fffffff3

14: -7 fffffff9

15: -4 fffffffc

16: -2 fffffffe

17: -1 ffffffff

18: -1 ffffffff

19: -1 ffffffff

User Avatar

Wiki User

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran

Add your answer:

Earn +20 pts
Q: How to use right shift operator with negative value in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp