C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28629
Number of posts: 94611

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
bitwise left shift operator Posted by snsuma on 3 Oct 2012 at 10:03 AM
hi
if we left shift 35 by 4 places, we are supposed to get result ( 35 x 2 to the power 4 ) according to definition of left shift operator but I am getting a different answer. why?

binary of 35 is 00100011
00100011 << 4 will result in 00110000 which is 48 where as the result should be 35 x 16 = 560.

please somebody help me
Report
Re: bitwise left shift operator Posted by WaltP on 5 Oct 2012 at 12:53 PM
If your value is in a byte (char) you loose all the bits above 255. So 35 (00100011) becomes 48 (00110000)



 

Recent Jobs