A part of me sees maths as simply one big game that involves numbers, its just that some of the ways that you play with these numbers can be particularly complicated, such as the following:
Now, I'm not going to attempt to solve, or show anybody, how to solve this particular equation, especially since it resulted in lots of people losing lots of money, but is one of the reasons why investment banks and the like are still willing to pay people with maths degrees and awful lot of money to work for them (and the guys that came up with it also won a nobel prize for the equation, though honestly, after it failed catastrophically, I'd want to take it back). Anyway, you can read more about it here.
Instead, we are going back to basics - sort of. While one might consider addition and subtraction to be relatively easy (even without a calculator), when we come to alternate number systems, things do get a little complicated. However, before I go any further, there is something of notation that I should mention. First of all, what are the following numbers?
If you said 'ten', 'ten', and 'ten' then unfortunately you would be wrong. In fact those numbers are actually 10, 2, and 8. The reason is that they are all different number systems, the first decimal, the second binary, and the third octal. So, how do we tell the difference? Well, if nobody has indicated what numbering system they are using, then you don't. However, to solve that problem, it is common to use subscripts, as follows:
Adding Things Up
So, now that we have that out of the way, let us first go to addition. Okay, I will assume that most people understand how to do arithmetic (without a calculator of course) so I won't go any further. However, remember how we used to do long addition, such as adding 7569 to 8167? The following is probably a reminder.
Now, you would add up the columns, starting from right and going left. However, if a the answer was over 10, you would put down the rightmost number, to put the one as a subscript in the next column. You would then add those numbers, as well as adding the one as well. If the resulting number also exceeded nine, you would do the same, until you had the answer.
Now, adding up binary numbers is pretty similar, except the problem is that you are only dealing with 0s and 1s. So, when you add 0 to 1 and vice verse you get, well, 1. However, what happens when you add 1 to 1. Well, you get 2, but 2 doesn't exist in binary so you need to carry the one, and the resulting answer is 10. However, what if you have already carried a 1? Well, the answer then becomes 11. An example follows:
Now, did I hear somebody suggest that there was an error. Shouldn't the answer be 11001001011? Well, yes, and no. Okay, this is only an example, but if you count the number of digits you will notice there are 10. Okay, 10 bit systems don't exist, since they basically increase by powers of 2, so it should actually be a 16 bit system. However, I did it this way to show something, namely what happens when it reaches the maximum limit - it drops.
Actually, I would say it crashes, and it can crash, as what happened with Gangum Style. What happens here is called a 'buffer overflow error' in that there isn't enough room for the total number of digits. Fortunately, these days computers are a little bit smarter than what they used to be, and usually what happens in this situation is that they just move on to the next load of data.
And Taking Them Away
I was going to add another section involving floating point numbers, but the lecturer has indicated that it isn't examinable. Then again, you can never go on what a lecturer says is examinable or not, because sometimes what is said won't be in an exam ends up being in an exam. However, the whole floating point concept is pretty intense and deserves a post in and of itself, so I'll just finish off here by talking about subtraction.
Now, when it comes to subtraction the rules unfortunately change - a lot. This isn't a simply method of simply subtracting 1s and 0s because, well, all you are dealing with are 1s and 0s, which means that it gets pretty confusing. Not just for us, but for the computers as well. Remember, this whole thing about binary is that we are attempting to speak to a computer in a language that a computer understands, and in many cases it is a completely foreign language (despite the fact that computers are artificial).
Now, let us get to negative numbers. Unfortunately, when we are using 0s and 1s there isn't an easy way to tell a computer whether there is a minus sign after the number. Well, actually, there is, but you need to do it using only 0s and 1s. This means that what we do is reverse the final bit to indicate whether it is a negative or a positive, where a 0 says positive, and a 1 says negative. As such 0001 will be 1, but 1001 will be -1.
Well, not quite, because you need to invert the whole number. so, 0001 is 1, but 1110 is actually -1. However, there is a problem. Can you work it out?
Yep, 1111 would in this instance be -0, but there is no such number as -0, so what they do is that they add 1 to the number so that we don't have that problem. This system is called twos complement. As such using four bits, we end up with the following system.
0000 0
0001 1 1111 -1
0010 2 1110 -2
0011 3 1101 -3
0100 4 1100 -4
0101 5 1011 -5
0110 6 1010 -6
0111 7 1001 -7
1000 8
Well, that seems to have caused us a little issue, because -8 becomes 1111, but we add 1 to it and it turns into 1 0000, but nothing is perfect. Anyway, we are working with 4 bits here, so 1000 is slightly out of our range.
So, when we are subtracting numbers, we convert the number we want to subtract into its negative, and then add them, as such (using 3-2):
0011
-1110
0001
Okay, so we have an answer (noting that the final one has dropped off). We need to take note that the final bit is a 0, so we don't have to do anything with it, so we have our answer: 1.
Let us do something different, let us try 3-5:
0011
-1011
1110
Okay, our answer is 1110, which looking above converts to -2. The reason we know this is because the final bit is a 1, which means that we are dealing with a negative number. If you do have to do any of this in an exam, it is always good simply to scribble the numbers on the page, so you can easily reference them.
ASCII and Unicode
So, we have numbers worked out, but what about all this other stuff you see on the screen, such as these letters and other symbols. Well, that is set up using a different system, though it is all binary to the computer. Originally they worked on a system called ASCII, or American Standard Code for Information Exchange, and was common for the old 8 bit machines. In fact ASCII only used 8 bits, which meant that it was limited to only 255 characters (and you should also note that in ASCII 1 isn't represented as '1', it is actually '011 0001'. Anyway, here are some more ASCII characters, though the full set can be found on wikipedia.
So, with there only being 255 characters to fiddle around with, how do we do things these days with our much more powerful, and much more fancy computers? Well, other than mining Bitcoins, they use a system call Unicode, which currently has over one million characters defined.
Anyway, I'll finish off here, and move on to Boolean Algebra (sort off).
Playing with Numbers - Addition & Subtraction by David Alfred Sarkies is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.This license only applies to the text and any image that is within the public domain. Any images or videos that are the subject of copyright are not covered by this license. Use of these images are for illustrative purposes only are are not intended to assert ownership. If you wish to use this work commercially please feel free to contact me
No comments:
Post a Comment