current position:Home>It's strange why the output is - 1

It's strange why the output is - 1

2022-02-02 22:32:07 CSDN Q & A

#include <stdio.h>
int main() {
printf("%d\n", -1 >> 1);
return 0;
}
Why does this output -1 ah




Refer to the answer 1:

C Two greater than signs in language >> Right shift operation , Is to discard the rightmost bits of the binary form of a number , Fill the top with the original highest number .




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022232060248.html

Random recommended