| We looked at Number Systems and counting (see | | | | and 2 outputs, one for the result (1 or 0), |
| It's a Binary World - How Computers Count) | | | | and a carry out, (1 or 0). In this case the |
| last time. As a quick refresher, we saw that | | | | carry input is not used. We use 2 XOR gates, |
| computers are made up of many units of 0 and | | | | 2 AND gates and an OR gate to make up the |
| 1, the binary system. 1 is the highest digit | | | | adder for 1 bit.Now we go another step, and |
| possible so numbers in the computer are | | | | forget about gates, because now we have a |
| stored as for example 1010 or 10 in decimal. | | | | Logic Block, an ADDER. Our computer is |
| We also saw that these binary numbers can be | | | | designed by using various combinations of |
| seen as octal (8) or hexadecimal (16) numbers | | | | logic blocks. As well as the adder we might |
| - in this case 1010 becomes 15 octal, or A | | | | have a multiplier (a series of adders) and |
| hex.You probably realise that the 'standard' | | | | other components.Our ADDER block takes one |
| PC code is in 8 bit bytes taking the hex | | | | bit (0 or 1) from each number to be added, |
| system a stage further. You may also know | | | | plus the Carry bit (0 or 1) and produces an |
| that processors, and Windows software that | | | | output of 0 or 1, and a carry of 0 or 1. A |
| runs on them, have progressed from 8 bits to | | | | table of the input A, B and carry, and output |
| 16 bits to 32 bits to 64 bits. | | | | O and Carry, looks like this:-With no Carry |
| | | | in:A B c O C |
| Basically this means the computer can work | | | | |
| on 1,2, 4 or 8 bytes at once. Don't worry if | | | | 0 0 0 0 0 |
| this is all Gobbledegook, you don't need it | | | | |
| to understand how computers add!OK now to the | | | | 1 0 0 1 0 |
| Math - cringe time! It's a little more | | | | |
| complicated than last time, but if you think | | | | 0 1 0 1 0 |
| logically, like a computer, realising they | | | | |
| are really dumb, you will sail through it!We | | | | 1 1 0 0 1With Carry in:A B c O C |
| take a break here to look at a bit of math | | | | |
| you may not have heard of - Boolean Algebra. | | | | 0 0 1 1 0 |
| Once again it's really simple, but it shows | | | | |
| you how a computer works, and why it is so | | | | 1 0 1 0 1 |
| pedantic!Boolean Algebra is named after | | | | |
| George Boole, an English Mathematician in the | | | | 0 1 1 0 1 |
| 19th Century. He devised the logic system | | | | |
| used in digital computers more than a century | | | | 1 1 1 1 1 This is known as a Truth Table, it |
| before there was a computer to use it!In | | | | shows output state for any given input |
| Boolean Algebra, instead of + and - etc. we | | | | state.Let's add 2+3 decimal. That is 010 plus |
| use AND and OR to form our logic steps.For | | | | 011 binary. We will need 3 ADDER blocks for |
| example:-x OR y = z means if x or y is | | | | decimal bit values of 1, 2 and 4)The first |
| present, we get z.However,x AND y = z means | | | | ADDER takes the Least Significant Bit |
| that both x and y need to be present to get | | | | (decimal bit value 1) from each number. Input |
| z.We can also consider an XOR (eXclusive | | | | A will be 0 Input B will be 1With no carry - |
| OR).x XOR y=z means that x or y BUT NOT BOTH | | | | 0.From the truth table this gives an output |
| must be present to get z.That's it! That's | | | | of 1 and a carry of 0 (3rd row).BIT 1 RESULT |
| all the math you need to understand how a | | | | = 1At the same time the next ADDER (decimal |
| computer adds. Told you it was simple!How do | | | | bit value 2) has inputs of A - 1, B - 1 and a |
| we use this logic in the computer? We make up | | | | carry of 0, giving an output of 0 with a |
| a little electronic circuit called a Gate | | | | carry bit of 1 (4th row).BIT 2 RESULT = 0At |
| with transistors and things, so we can work | | | | the same time the next ADDER (decimal bit |
| on our binary numbers stored in a register - | | | | value 4) has inputs ofA - 0, B -0 and a carry |
| just a bit of memory. (And that's the last | | | | of 1, giving an output of 1 with no carry - 0 |
| electronics you'll hear about!). We make an | | | | (5th row). |
| AND gate, an OR gate, and an XOR gate.When we | | | | |
| add in decimal, for example 9+3 we get 2 | | | | BIT 4 RESULT = 1.So we have bits 4,2,1 as |
| 'units' and carry one to the 10s, giving | | | | 101 Binary or 4+0+1=5 decimal.It seems like a |
| 10+2=12Remember the binary bit values in | | | | laborious way to do it, but our computer can |
| Decimal - 1,2,4,8 etc? We start at 0, then 1 | | | | have 64 adders or more, adding simultaneously |
| in the first bit position, the 1 bit. If we | | | | two large numbers billions of times a second. |
| add 1 + 1 binary we have to end up with 10, | | | | This is where the computer scores.Next time |
| which has a 1 bit in the second bit position, | | | | we will get to how a computer performs more |
| and a 0 in the first, giving Decimal | | | | complcated operations, and it's simple!Tony |
| | | | is an experienced computer engineer. He is |
| 2+0=2. This second bit position is formed by | | | | currently webmaster and contributer to |
| a CARRY from the first bit.To make an adder | | | | looking at things you can do At Home. A set |
| we must duplicate with a logic circuit the | | | | of diagrams accompanying these articles may |
| way we add in binary. To add 1+1 we need 3 | | | | be seen on that website. Go to to start. |
| inputs, one for each bit, and a carry in - | | | | |