嘿我试图弄清楚为什么-1 << 4(左)移位是FFF0在浏览和浏览网络后我发现"负"数字有一个符号位,即1.因为只是因为"-1"意味着额外的1位,即(33)位,这是'牛逼可能这就是为什么我们认为-1作为1111 1111 1111 1111 1111 1111 1111 1111
例如 :-
#include<stdio.h>
void main()
{
printf("%x",-1<<4);
}
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我们知道 -
Internal representation of -1 is all 1’s 1111 1111 1111 1111 1111 1111 1111 1111 in an 32 bit compiler.
When we bitwise shift negative number by 4 bits to left least significant 4 bits are filled with 0’s
Format specifier %x prints specified integer value as hexadecimal format …Run Code Online (Sandbox Code Playgroud)