From the course: Computer Science Principles: Digital Information

Abstraction of numbers

From the course: Computer Science Principles: Digital Information

Start my 1-month free trial

Abstraction of numbers

- When we think about numbers, we think of, well, numbers, anything that has a digit that could be zero through nine. So, for example, we have a number like seven, two, three. This number seven, two, three represents a value or a count of something. It could be $723, 723 yards of yarn, or 723 gallons of milk. The number tells us how much of something there is. What if I showed you these three numbers? What if I told you that each of these numbers actually represented different amounts of something? It's totally possible through the use of different number systems. Let's throw away numbers as we know them for a moment and look at a pile of stuff. In this case, I have five paper clips. Now we can represent this with a five. But if I said I have this many paper clips, does that mean the same thing? Yes, it does, if you understand Roman numerals. Roman numerals are another way to measure how much of something we have. It follows a different set of rules, using symbols like I, V, X, L, C, and M. Roman numerals are based on basic counting. Starting at one, I add symbols, and then at a certain point I use the next largest symbol, and either add or subtract from that value, with the understanding that there can only be three consecutive symbols of the same type. Confusing? Yeah, kind of, but for centuries Roman numerals had been used either as the basic form for all representations of value back in the Roman days, to counting annual sporting events or movie sequels today. But this shows that there can be more than one way to represent the same value. We ordinarily represent numbers using the decimal number system. Decimal uses a base 10 for the number system, which is why there are ten digits that we use for numbers, zero, one, two, three, four, five six, seven, eight, and nine. The other key part of a number system is the fact that you can have multiple digits. So for example, we can take number five, and we can represent that as a single digit. But for the number 15, we need two digits. The digit on the right represents ones. The next digit to the left represents tens. We can represent this like an old-style odometer, where all the possible digits can be shown in the column. When you get to the highest digit, you need to add one more. You push the value to the next column, and start over from zero. There is some cool math that goes with these columns. Remember when I said that the decimal number system is based on ten? Well, you can represent that first column as taking the single digit and multiplying it by 10 to the power of zero, which is one. As you move to the left, you can take the exponent and increase it by one for as long as you need to. So the next colum is 10 to the power of one, which is ten. Multiply by the digit in the column. So if we take a more complicated example, like our earlier seven, two, three, you can calculate what each column represents, and when you add all these up, you come back to seven, two, three. What if I took the number of possible digits, and cut off the last two? In this case, it would only have eight digits, representing a new number system based on eight, or the octal number system. I now need to change the calculatons for the column, and instead of using 10, I need to use eight. So now if we use the same format to calculate each column, the octal number of seven, two, three actually is four, six, seven in decimal. I can also add possible digits. For example, I can create 16 possible digits. After nine, I can use letters like A, B, C, D, E, and F to represent the additional digits. This number system is based on 16 and is called the hexadecimal number system. So seven, two, three in hexadecimal, when we update our formulas for the columns of the digits, actually represents what we would recognize as one, eight, two, seven in decimal. You'll often see hexadecimal when you do coding, especially in a web design. Colors represented by a series of three or six hexadecimal numbers, with the first group representing red, the second group as green, and the last as blue. On screen you're controlling the amount of red, green, and blue light in each pixel. So these numbers represent these values, allowing you to increase or decrease each one, to give you millions of different color choices. So if you think of the rules of the number systems, you have a few things that are the same. You have the base number, which describes the maximum number of possible digits, and then you have multiple columns, that are incremented exponentially the further you go to the left to make larger values. This also works the other way, to make smaller numbers, too. With those rules, you can apply them to any base number, including two, which is the basis of the binary number system, and serves as the foundational way computers store, communicate, and process information.

Contents