This week's giveaway is in the Android forum. We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line! See this thread for details.

Hi, I know this is a lame question but I had lot of doubts in it. Can any body explain taking a -ve number convert it to binary form and show the << and >> shifts of it. Thanks in bunches, madhuri.

Hi mukthi, Thankyou very much for the site . It is very explanative and very clear.Thankyou once again. Madhuri.

madhuri vl
Ranch Hand

Joined: Jan 17, 2001
Posts: 86

posted

0

Hi, I got the site and understood fairly how to represent a negative number in binary form and left and right shift of postive numbers. For example -13 binary is 1111 0011 and -13 >> 3 = 1111 1110. I don't know how to interprete this as decimal number. Can anybody explain please? Thanks in advance, Madhuri.

Hi Madhuri, Here's a link to some notes I have posted on Binary/Octal/Decimal/Hex converstions. Hope they help. ------------------ Jane Griscti Sun Certified Java 2 Programmer [This message has been edited by Jane Griscti (edited February 12, 2001).]

Hi Jane, The site given by you is so good but I still have the doubt for -13>>3 1111 1110 which is equal to -2. Even in your sight there is anumber -16>>2 which is equal to -4. The only part I did not understood is the calc part to arrive at -2 from 1111 1110 or in the -16 example. Please try to explain. Madhuri.

The way to find out the value of that number is -i = (~i)+1 which means in your case: ~1111 1110 +1 = 0000 0001(bin)+1(bin) = 0000 0010(bin) = 2 (dec) Therefore the value is -2 If you want to present -i = (~i)+1 16(dec) = 0001 0000 ~16 = 1110 1111 ~16+1 = 1111 0000

madhuri vl
Ranch Hand

Joined: Jan 17, 2001
Posts: 86

posted

0

Hi, I got solution for this from Marcusgreen tutorials where he has an applet giving the result. Anyway thankyou and can u please show one example for a -ve num with >>>. like -2 >>> 2. Thankyou in advance.