This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I still cannot understand how are we supposed to calculate such nos. I went through a mock and found a question : 128 >> 1 gives 64 128 >>> 1 gives 64 128 << 1 gives 256
Ans : All are true.Can any one explain me how is the above expressions true?..with EXPLAINATIONS!! Sonir
Jim Hall
Ranch Hand
Joined: Nov 29, 2001
Posts: 162
posted
0
This has been discussed many times. Do a search in this forum for "shift".
sagar patil
Greenhorn
Joined: Jan 04, 2002
Posts: 2
posted
0
Let me C if I cud B of help..... these R really crude methods.... RightShift x >> n simply means divide x by (2^n) thus eg no 1. 128 >> 3 means 128 / (2^3) =128 / 8 =16 eg no. 2 127 >> 3 =127 /8 =15 (forget the decimal business...) Catch here is of -ve numbers ::: -127 >> 3 = -(15+1) = -16 Similarly, LeftShift means multiply by 2^n thus 12 << 3<br /> =12*8<br /> =96<br /> Now comes the unsigned right shift >>> For positive numbers its the same as >> so 128 >>> 3 =128/8 =16 for -ve numbers the fundas R required.... no crude methods can help U with these ...
When the going gets tough,<br />the TOUGH get going.....