#include <iostream>
int main()
{
unsigned s=555;
int i=(s>>4) & ~(~0<<3);
std::cout<<i;
system("PAUSE");
return 0;
}
我的算法是這樣:
unsigned s=555
也就是說二進位是0000001000101011
右移4bit後=0000000000100010
not 0=1
1左移3bit後=00000000000001000
not運算後 =11111111111110111
再 and 00000000000100010