1: main()
2: {
3: unsigned int num = 0xcccccccc;
4: unsigned int res = 0,b1= 0,count=0;
5: printf("Num : 0x%x\n",num);
6: while(num)
7: {
8: if(num & 1)
9: {
10: b1 = (b1 << 1) | 1;
11: count++;
12: }
13: num >>= 1;
14: }
15: num = b1 << count;
16: printf("Result : 0x%x\n",num);
17: }
RTOS, Linux Kernel internal, OS-Programming C & Data Structures, Debugging, Optimizations, Makefiles and Wireless Technologies (Wi-Fi ,LTE and LTE-Advanced )
Search This Blog
Sunday, October 5, 2014
WAP to shift all one's at one side in a given 32-bits number. i.e num = 0xcccccccc o/p - 0xffff0000
Labels:
C
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment