cookertron Posted May 26, 2011 Share Posted May 26, 2011 I'm working on a theory but my maths is as good as a chimps so I'd really appreciate some advice. I'm trying to find out if it's possible to add a single bit to a binary number without using a computer, for example; 19 = 10011 If I add a single bit (1) then the result is 20 = 10100 so on and so for... If I didn't have a computer how would I be able to work that out in a mathematical way? I can generate an alternating binary switch by using this simple loop a = 1 b = a - b My objective: c = c + b The problem is that b is in binary form so c must also be binary in order to increment the counter? I hope you understand my objective. Any help would be greatly received, even if it's to say it's impossible. regards cookertron Link to comment Share on other sites More sharing options...
CaptainPanic Posted May 26, 2011 Share Posted May 26, 2011 I am not sure what you mean... I think that a computer is by definition a machine that can do calculations in binary. In the old days, computers used to be mechanical (but still binary). And very simple mechanical computers are relatively easy to understand. But they are still called computers. Link to comment Share on other sites More sharing options...
md65536 Posted May 26, 2011 Share Posted May 26, 2011 (edited) If I didn't have a computer how would I be able to work that out in a mathematical way? Well, if you compute the answer (whether the computer is electronic, or your brain, or water logic gates or anything) you'd use a computer. If you say had a huge lookup table of binary numbers with one-bit add results (a sequential list of numbers?) you could find the answer without computing it. But I think what you're asking for is an algorithm to work out the answer by hand or in your head. A simple algorithm for adding numbers can be the same for binary or decimal. When you add a 1 to an arbitrary decimal number, you are using an algorithm. For example, a typical way for people to add 2 arbitrary numbers is this: 1. Add the least significant digits together. If it exceeds the maximum value of a digit, then carry the one to the next least significant digit. 2. Add the next least significant digits plus the carry. Again carry the 1 if there is one. 3. Repeat step 2 for all digits. For binary numbers the only other information needed is to know how to add 2 bits plus a carry: 0 + 0 = 0 0 + 1 = 1 + 0 = 1 1 + 1 = 0 with carry 0 + 0 + carry = 1 0 + 1 + carry = 1 + 0 + carry = 0 with carry 1 + 1 + carry = 1 with carry This is typically how humans add: Memorize a table of one-digit addition, and use a loop and simple rules to compute arbitrarily large numbers. Computers use logic that doesn't require the loop or "cascade". For adding just a single bit, there are simpler algorithms. http://www.wikihow.com/Add-Binary-Numbers might explain it simpler. Edited May 26, 2011 by md65536 Link to comment Share on other sites More sharing options...
TonyMcC Posted May 26, 2011 Share Posted May 26, 2011 I'm not really sure what you are looking for. But, it is realatively easy to do addition when the two numbers to be added are both binary numbers. The rule is simply 1+0=1 and:- 1+1=0 and carry 1 Just work your way from right to left. You will find that you will generate a carry for the first two rows when you add 1 to 10011. Link to comment Share on other sites More sharing options...
John Cuthber Posted May 26, 2011 Share Posted May 26, 2011 I guess it depends on your definition of "computer" but this will do binary addition for you and it's just a combination of logic gates. http://en.wikipedia.org/wiki/Adder_(electronics) you can replace the logic gates with a pencil and paper if you like. It will, of course, give the same answer as TonyMcC's method. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now