Shown above is a memory cell, which can do all of that. This is because it can’t remember anything, and does nothing with its outputs. Right now, our computer is nothing more than a bad calculator.
And while all modern computers have hardware-based solutions to speed up more complicated operations, you can technically do it all with the full adder. Most other math operations can be done with addition multiplication is just repeated addition, subtraction can be done with some fancy bit inversion, and division is just repeated subtraction. Moving up to more bits essentially just means more full adders in a longer chain. When both inputs are on, the carry turns on, and sends it to the next full adder in the chain:Īnd this is about as complex as addition gets. The carry is added to the result of the XOR gate in the first half adder, and there’s an extra OR gate to handle both cases when the so that would need to be on. Full adders will be linked in a chain, and the carry is passed from one adder to the next. The full adder has three inputs-the two numbers to add, and a “carry.” The carry is used when the final number exceeds what can be stored in a single bit. But this is only a half adder, and if you connect two of them with another input, you get a full adder: But one bit can’t store anything higher than 1, and this machine isn’t too useful as it only solves one of the simplest math problems possible. This gives us a simple setup with three distinct outputs: zero, one, and two. So if both are on, the XOR stays off, and the AND gate turns on, coming to the correct answer of two: The AND gate will turn on if both inputs are on, but stay off if there’s no input. The XOR gate here will turn on if just one of the inputs is on, but not both.
This diagram above shows a half adder, created using Logicly, a free online playground for logic gates. With just two gates you can do basic binary addition. RELATED: How Logic Gates Work: OR, AND, XOR, NOR, NAND, XNOR, and NOT Doing Math With Gates The AND gate checks if both inputs are true, XOR checks if only one of the inputs are true, and the N-variants (NOR, NAND, and XNOR) are inverted versions of their base gates. The OR gate, for example, returns true if either of the inputs is true. Logic gates take two binary inputs, perform an operation on them, and return an output. Stack a few transistors properly, and you have what’s known as a logic gate. Modern computers use billions of transistors to perform calculations, but at the lowest levels, you only need a handful to form the most basic components, known as gates. RELATED: What is Binary, and Why Do Computers Use It? Essentially, this forms a binary switch, which cuts the wire off depending on a second input signal. The transistor only allows the source current to flow through it to the drain if there is current across the gate. To perform calculations in binary, they use what’s called a transistor. They only understand two states: on and off.