Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   sum = (sum >> 16) + (sum & 0xffff) (http://www.go4expert.com/forums/sum-sum-16-sum-0xffff-t21243/)

en_7123 7Mar2010 18:41

sum = (sum >> 16) + (sum & 0xffff)
 
What does this statement mean in c
sum = (sum >> 16) + (sum & 0xffff)
Thanks

techgeek.in 7Mar2010 20:23

Re: sum = (sum >> 16) + (sum & 0xffff)
 
the above expression can be represented as:-

sum=sum/(2^16) +sum


becoz, (sum >> 16) means the sum divided by 2 to the power 16.. (refer to the meaning of bitwise left shift and bitwise right shidt)
and
(sum & 0xffff) itself gives sum.


All times are GMT +5.5. The time now is 13:27.