Hi, This sounds like I should go back to kiddies school for posting something so rudimentary as this, but one of the big problems Ive had in sitting pass papers is the shift operators (>>, <<, >>>) and negative numbers. Ive got the exam coming up this Wednesday. You see I can count positive numbers in binary ie 0001 = 1 0010 = 2 0011 = 3 and so on and so forth But negative numbers..... I cant! I can understand how the shift operators work, but unfortunately not how to count negative numbers in binary Any help would be greatly appreciated! Cheers, Mark

to get the negative counterpart of a positive number you have to do the following: 00101101 = 45 There are two basic steps to perform: 1. change all 0's to 1's and 1's to 0's 11010010 2. add 1 to the result 11010011 this last bit sequence is -45 (you notice the 1 on the left which indicates that it is a negative number) HIH ------------------ Valentin Crettaz Sun Certified Programmer for Java 2 Platform

Thanks Valentin! Thats allowed me to answer a lot of questions that I might otherwise have got wrong... Ive just gone over all the pass papers with those kind of questions and Ive got them correct! Thanks for your help, Mark

Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610

posted

0

Good job Mark ------------------ Valentin Crettaz Sun Certified Programmer for Java 2 Platform

Don't get me started about those stupid light bulbs.

subject: Help counting negative numbers in binary!