This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
Joined: Aug 26, 2001
Good job Mark ------------------ Valentin Crettaz Sun Certified Programmer for Java 2 Platform
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Help counting negative numbers in binary!