Additive Numbering Systems and Numbers of Different Bases MAT 142 RSCC Scott Surgent Our modern numbering system uses ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. These are known as the Hindu-Arabic symbols. Because we have ten symbols, we count in a base-10 numbering system. Recall what happens to the number 10 when raised to integer powers: 10 0 = 1 10 0 10 2 = 100 10 3 = 1,000 10 4 = 10,000 10 5 = 100,000 10 6 = 1,000,000 Etc. When we write a number like 2,458, we are really saying 1,000 + 1,000 + 100 + 100 + 100 + 100 + 10 + 10 + 10 + 10 + 10 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 2 10 3 4 10 2 5 10 1 8 10 0 This is known as an additive numbering system, and also as a place-holder numbering system. With practice, we see a number like 2,458 as representing two batches of 1,000, four batches of 100, 5 batches of 10, and 8 batches of 1. Other bases: Base 2 (binary). Symbols used: 0 and 1. Powers of 2: 2 0 = 1 2 1 = 2 2 2 = 4 2 3 = 8 2 4 = 16 2 5 = 32 2 6 = 64, etc. A number written in binary would look like 1001101. Expanded, we have 1(2 6 ) + 0(2 5 ) + 0(2 4 ) + 1(2 3 ) + 1(2 2 ) + 0(2 1 ) + 1(2 0 ). The 0s simply drop out that portion of the number. What s left is 1(2 6 ) + 1(2 3 ) + 1(2 2 ) + 1(2 0 ) = 1(64) + 1(8) + 1(4) + 1(1) = 77. To write a base-10 number into binary, we need to think of how to write the base-10 number using portions of size 1, 2, 4, 8, 16, 32, 64, and so on, at most once. For example, the base-10 number 93 can be written as 64 + 16 + 8 + 4 + 1. Thus, 93 = 1(64) + 0(32) + 1(16) + 1(8) + 1(4) + 0(2) + 1(1) = 1011101. To add two binary numbers, we use the basic rules: 0 + 0 = 0, 1 + 0 = 1, 0 +, and 1 + 0 ( carry the one ). Note, this last one is not one plus one equals ten. It is 1 (base 2) + 1 (base 2 ) = 10 (base 2). The binary number 10 represents 2.
Example: Find 110011 + 100101 Solution: Add columns right to left, like you would normally. Whenever you encounter a 1 + 1, write a 0 below, and carry the extra 1 to the next column to the left. Thus, 110010010011000. Converted into base-10, we have 110011 = 51, 100101 = 37, and 51 + 37 = 88, which is 64 + 16 + 8, or 1011000. Computer circuit boards rely on this basic form of arithmetic to add and multiply binary values. It is very tedious for humans to perform this by hand, but a computer can handle trillions of these calculations in mere seconds. The most complicated computer programs in the world are ultimately just a huge sequence of 0s and 1s being added again whenever necessary, faster than you can shake a stick at. Binary numbers and their base-10 equivalents: 2 = 10 3 = 11 4 = 100 5 = 101 6 = 110 7 = 111 8 = 1000 9 = 1001 10 = 1010 1011 12 = 1100 13 = 1101 14 = 1110 15 = 1111 16 = 10000 17 = 10001 18 = 10010 19 = 10011 20 = 10100 20101 22 = 10110 23 = 10111 24 = 11000 25 = 11001 26 = 11010 27 = 11011 28 = 11100 29 = 11101 30 = 11110 31111 32 = 100000 33 = 100001 34 = 100010 35 = 100011 36 = 100100 37 = 100101 38 = 100110 39 = 100111 40 = 101000
Base 3 (trinary) Symbols used: 0, 1 and 2 Powers of 3: 3 0 = 1 3 1 = 3 3 2 = 9 3 3 = 27 3 4 = 81 3 5 = 243 3 6 = 729, etc. A trinary number looks like 2101102. It is 2101102 = 2(3 6 ) + 1(3 5 ) + 0(3 4 ) + 1(3 3 ) + 1(3 2 ) + 0(3 1 ) + 2(3 0 ) = 2(729) + 1(243) + 0(81) + 1(27) + 1(9) + 0(3) + 2(1) = 1458 + 243 + 27 + 9 + 2 = 1739 (base 10). To convert a base-10 number like 475 into base 3, we need to split 475 into portions of size 1, 3, 9, 27, 81, 243, 729, and so on, where we can use 0, 1 or 2 of each portion. Note that 729 is too big, but 243 is smaller than 475, so we have 475 1(243) = 232. Then, from 232 we can write using two portions of size 81, so we have left 232 2(81) = 70. From 70, we can take two portions of size 27, so we have left 70 2(27) = 16. From 16, we can take 1 portion of size 9, so we have left 16 1(9) = 7. From 7, we can take two portions of size 3, so we have left 7 2(3) = 1. Finally, 1 is one portion of size 1, or 1(1), so we are finished. So, we have 475 (base 10) = 1(243) + 2(81) + 2(27) + 1(9) + 2(3) + 1(1) = 122121 (base 3). There exist numbering schemes for base 4, 5 and so on. Some of the more common are base 8 (octal) and base 16 (hexadecimal), which are used commonly in computer languages. Powers of 2, such as 8 and 16, are desirable because they can be halved and doubled easily. Ironically, base-10 is not a convenient numbering system in computer programming. Trinary numbers and their base-10 equivalents: 2 = 2 3 = 10 4 = 11 5 = 12 6 = 20 7 = 21 8 = 22 9 = 100 10 = 101 102 12 = 110 13 = 111 14 = 112 15 = 120 16 = 121 17 = 122 18 = 200 19 = 201 20 = 202 21 = 210 22 = 211 23 = 212 24 = 220 25 = 221 26 = 222 27 = 1000 28 = 1001 29 = 1002 30 = 1010 3011 32 = 1012 33 = 1020 34 = 1021 35 = 1022 36 = 1100 37 = 1101 38 = 1102 39 = 1110 40 = 1111
Base 8 (Octal) Symbols used: 0, 1, 2, 3, 4, 5, 6, 7. Powers of 8: 8 0 = 1, 8 1 = 8, 8 2 = 64, 8 3 = 512, 8 4 = 4096, etc. Example: Write 4763 (base 8) into base 10. Solution: We have 4763 (base 8) = 4(8 3 ) + 7(8 2 ) + 6(8 1 ) + 3(8 0 ) = 4(512) + 7(64) + 6(8) + 3(1) = 2,547 (base 10) Example: Convert 12,877 (base 10) into Octal (base 8). Solution: Thus, The largest power of 8 that is less than 12,877 is 8 4 = 4096. Note that we can remove three portions of 4096, so we have 12,877 3(4096) = 589. From 589, we can remove one portion of 8 3 = 512, so we have 589 1(512) = 77. From 77, we can remove one portion of 8 2 = 64, so we have 77 1(64) = 13. From 13, we can remove one portion of size 8 1 = 8, so we have 13 1(8) = 5. We have 5 portions of size 8 0 = 1, or 5(1). 12,875 (base 10) = 3(8 4 ) + 1(8 3 ) + 1(8 2 ) + 1(8 1 ) + 5(8 0 ) = 31115 (base 8). Octal numbers and their base-10 equivalents: 2 = 2 3 = 3 4 = 4 5 = 5 6 = 6 7 = 7 8 = 10 9 = 11 10 = 12 13 12 = 14 13 = 15 14 = 16 15 = 17 16 = 20 17 = 21 18 = 22 19 = 23 20 = 24 21 = 25 22 = 26 23 = 27 24 = 30 25 = 31 26 = 32 27 = 33 28 = 34 29 = 35 30 = 36 31 = 37 32 = 40 33 = 41 34 = 42 35 = 43 36 = 44 37 = 45 38 = 46 39 = 47 40 = 50 62 = 76 63 = 77 64 = 100 65 = 101 66 = 102 Question: What octal number comes after 7777? Answer: 10000.
Base 16 (Hexadecimal) Symbols used: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F Note that A represents ten, B eleven, C twelve, D thirteen, E fourteen and F fifteen. Powers of 16: 16 0 = 1 16 6 16 2 = 256 16 3 = 4096 16 4 = 65,536, etc Example: Write 501A (hexademical) into its base-10 equivalent. Solution: Break it apart as 501A = 5(16 3 ) + 0(16 2 ) + 1(16 1 ) + A(16 0 ) = 5(4096) + 1(16) + 10(1) = 20,506 (base 10) Example: Write 52,748 (base 10) into hexadecimal. Solution: We need to break this number into portions of 1, 16, 256, 4096, 65536, and so on, using each portion at most 15 times. 65,536 is too big, so we move down to 4096. Note that 12 portions of 4,096 is less than 52,748. Thus, we have 52,748 12(4,096) = 3,596. Note that 14 portions of 256 is less than 3,596. Thus, we have 3,596 14(256) = 12 Since 12 is less than 16, we have 12 portions of 16 0, or 12(1). The hexadecimal symbols for 12 is C and for 14 is E, so 52,748 (base 10) is equivalent to CEC (hexadecimal). Hexadecimal was used often (is probably still used often) when compiling computer programs into a more digestible format for computers to understand. For example, the old language BASIC would look like this: 10 FOR A = 1 TO 10 20 PRINT A, A*A 30 NEXT 40 END This program prints the first ten numbers and their squares. The language itself used codes, such as common English words like FOR, PRINT and NEXT to perform tasks. In building a language that has many levels of coding, it slows down the run-time of such a program. Thus, you would create a program in BASIC, then run it through a hex-compiler, which would convert the program into a long string of hexadecimal numbers. It allowed programs to run faster because the computer did not need to slow down each time it came to a code such as NEXT. Hexadecimal numbers and their base-10 equivalents 2 = 2 3 = 3 4 = 4 5 = 5 6 = 6 7 = 7 8 = 8 9 = 9 10 = A 11 = B 12 = C 13 = D 14 = E 15 = F 16 = 10 17 = 11 18 = 12 19 = 13 26 = 1A (16 + 10) 30 = 1E 3F 32 = 20 33 = 21 42 = 2A (2(16) + 10) 43 = 2B 44 = 2C 47 = 2F 48 = 30 254 = FE 255 = FF 256 = 100 257 = 101 266 = 10A (256 + 10)