Binary Adding Machine

2 min read


Charles Petzold's "Code: The Secret Language of Computer Hardware and Software" has been a favourite of mine. You can find it here. I strongly recommend this book, particularly if you're just beginning to learn about computer science. Charles does a wonderful job of explaining complex topics in a digestable and easy to understand manner for beginners. You can also find a second edition here.



Charles shows how to create an adding machine in binary format that adds two binary numbers with a size of 8 bits. I decided to create an implementation of this machine in Minecraft and also in JavaScript. You can find the complete JavaScript repository here.



This article will show you how to complete the entire procedure step-by-step. I will demonstrate how I was capable of following the directions in chapter twelve to build this machine in both JavaScript and Minecraft. If you would like a more thorough explanation of any of the following topics I would suggest you go through chapter 12 of the book mentioned above.



Introduction



To add two 8-bit binary numbers first, we need to be capable of adding two binary numbers of one bit. The sum of these two 1-bit numbers will result in an integer of two bits. ACESASOFT We'll call the first part of this 2-bit number the "sum" bit and the second part the "carry" part. If you want to sing a song about it, you could say:



0 plus 0 equals 0.



0 plus 1 equals 1.



1 plus 0 equals 1.



1 plus 1 equals 0, carry the 1.



The table below shows the sum of our two 1-bit numbers.



Logic Gates



To accomplish this, we'll need make some logic gates. We'll begin with the AND gate, since we can use it to calculate the carry bit. Here is the gate I've built in Minecraft (with a little help from Mumbo Jumbo).

In case you have found a mistake in the text, please send a message to the author by selecting the mistake and pressing Ctrl-Enter.
Comments (0)

    No comments yet

You must be logged in to comment.

Sign In / Sign Up