SHIFTEM.C
上传用户:qq5388545
上传日期:2022-07-04
资源大小:29849k
文件大小:1k
- #include <stdio.h>
- void main(void)
- {
- unsigned u_val = 1;
- signed int value = -1;
- printf("%u (unsigned) shifted left 2 times is %un",
- u_val, u_val << 2);
- printf("%u (unsigned) shifted right 2 times is %un",
- u_val, u_val >> 2);
- u_val = 65535;
- printf("%u (unsigned) shifted left 2 times is %un",
- u_val, u_val << 2);
- printf("%u (unsigned) shifted right 2 times is %un",
- u_val, u_val >> 2);
-
- printf("%d (signed) shifted left 2 times is %dn",
- value, value << 2);
- printf("%d (signed) shifted right 2 times is %dn",
- value, value >> 2);
- }