Tuesday 9 October 2012

Topic 1 Subtopic 2: Number system base

Base is a number or quantity which is arbitrarily made the fundamental number of a system. The basic 4 type of the base system are Binary, Octal,Decimal, and hexadecimal.

The different numeral systems like the binary, hexadecimal and sometimes octal that computer will be working with lots of times that you will be use and you should know how to convert numbers from one numeral system to the other. The digits that all 4 numeral systems use are shown below :

Decimal Binary Hexadecimal Octal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
0 1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
10000
0 1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
10
0 1
2
3
4
5
6
7
10
11
12
13
14
15
16
17
20

Base-10

Base 10 refers to the numbering system in common use. Take a number like 123, base ten refers to the position, the 3 is in the one's place, the 2 is in the ten's place and the 1 is in the hundred's place. Each number is 10 times the value to the right of it, hence the term base ten. The numbers continue indefinitely in this pattern: 100000,10000,1000,100,10,1 0.1, 0.01, 0.001, 0.0001, 0.00001


Base-10 Mathematically

You may have noticed a pattern by now. Let’s look at what is going on mathematically, using 1234 as an example.
  • As you saw, there are 1 groups of a thousand. Not coincidentally, 1000 = 10*10*10 which can also be written as 103.
  • There are 2 groups of a hundred. Again, not coincidentally, 100 = 10*10 or 102.
  • There are 3 groups of ten, and, 10 = 101.
  • Finally, there are 4 groups of one, and 1 = 100. ( any number to the power of 0 equals 1.)
This is essentially the definition of base-10. To get a value of a number in base-10, we simply follow that pattern. Here are a few more examples:
  • 892 = 8*102+9*101+2*100
  • 1147 = 1*103+1*102+4*101+7*100
  • 53 = 5*101+3*100


Base-8

On to base-8, also called octal. Base-8 means the system is based on the number eight. In base-8, there are limited to only eight digits: 0, 1, 2, 3, 4, 5, 6, and 7. We count the same way as we normally would, except with only eight digits. There’s no such thing as 8 or 9 in system base 8.
You should notice a similar pattern to before; after we get to 7, we run out of different digits for any higher number. We need a way to represent eight of something. So we add another digit, change the 7 back to 0, and end up with 10. Our answer of 10 in base-8 now represents what we would normally think of as 8 in base-10. Unlike base 10, a standard notation where a subscript denotes the base of numbers is needed for base 8. For example, our base-8 version of 10 is looks like 108. Great, so we know 108 represents base eight items. What’s the next number after 778? If you said 1008, you’re correct. We know from what we’ve learned so far that the first 7 in 778 represents groups of 8, and the second 7 represents individual items. If we add these all up, we have 7*8 + 7*1 = 63. So we have a total of 6310. So 778=6310. We all know 6410 comes after 6310.

Converting From Base-8 to Base-10

Let’s look at a example now. John offers to give you 468 biscuit, and Jane offers to give you 5510 cookies. Whose offer do you take?  Let’s figure out its base-10 value so we can make the best decision!
As we saw when counting, the four in 8 represents the number of groups of eight. This makes sense – we are in base-8. So, in total, we have four groups of eight and six groups of one. If we add these all up, we get 4*8 + 6*1 = 3810. So, 468 cookies is the exact same as 3810 cookies. Jane’s offer seems like the best one now!
The pattern we saw before with base-10 holds true here also. We’ll look at 5238. There are five groups of 82, two groups of 81 and three groups of 80 (remember, 80=1). If we add these all up, 5*82 + 2*81 + 3*80 = 5*64+2*8+3 = 339, we get 33910 which is our final answer. The diagram below shows the same thing visually:
Converting 523 from base-8 to base-10
Here are a couple more examples:
  • 1118 = 1*82+1*81+1*80 = 64+8+1 = 7310
  • 438 = 4*81+3*80 = 32+3 = 3510
  • 61238 = 6*83+1*82+2*81+3*80 = 3072+64+16+3 = 315510

Converting from Base-10 to Base-8

Converting from base-10 to base-8 is a little trickier, but still straightforward. We basically have to reverse the process from above. Let's start with an example: 29110. We first find the largest power of 8 that is smaller than our number. Here, this is 82 or 64 (83 is 512). We count how many groups of 64 we can take from 291. This is 4, so the first digit in our base-8 number is 4. We have now accounted for 128 out of 291, so we have remainder 35 left over. The largest power of 8 that is smaller than 35 is 81 (that is, 8). How many groups of 8 can we take from 35? Four groups again, and thus our second digit is 4.
Finally, we are left with 3, and can obviously take 3 groups of one from this, our final digit. We end up with 4438.
In fact, we can make this process a touch clearer with math. Here are the steps:
  1. 291/82 = 4 remainder 35
  2. 35/81 = 4 remainder 3
  3. 3/80 = 3
Our final answer is then all of our non-remainder digits, or 443. Notice that we still start by dividing by the highest power of 8 that is less that our number.

Dealing with any Base

It's important to be able to apply the concepts we've learned about base-8 and base-10 to any base. Just as base-8 had eight digits and base-10 had ten digits, any base has the same number of digits as its base. So base-5 has five digits (0-4), base-7 has seven digits (0-6), etc.
Now let's see how to find the base-10 value of any number in any base. Say we are working in base-b, where b can be any positive integer. We have a number d4d3d2d1d0 where each d is a digit in a number. (The subscripts here don't refer to the base of the number but simply differentiate each digit.) Our base-10 value is simply d4*b4 + d3*b3 + d2*b2 + d1*b1 + d0*b0.
Here's an example: we have the number 32311 in base-4. Notice how our number only has digits from zero to three since base-4 only has four total digits. Our base-10 value is 3*44 + 2*43 + 3*42 + 1*41 + 1*40 = 3*256 + 2*64 + 3*16 + 1*4 + 1*1 = 949. We could, or course, follow this pattern with any amount of digits in our number.

Base-16

Base-16 is also called hexadecimal. It's commonly used in computer programming, so it's very important to understand. Let's start with counting in hexadecimal to make sure we can apply what we've learned about other bases so far.
Since we are working with base-16, we have 16 digits. So, we have 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...  We have no value to represent after 10. How then? Instead, we simply use letters of the alphabet, starting with A and continuing to F which represent value 10 to 15 in hexadecimal. Here's a table with all the digits of base-16:
Base-16 digits
Other than these extra digits, hexadecimal is just like any other base.
For example, let's convert 3D16 to base-10. Following our previous rules, we have: 3D16 = 3*161 + 13*160 = 48 + 13 = 61. So 3D16 is equal to 6110. Notice how we use D's value of 13 in our calculation.
We can convert from base-10 to base-16 similar to the way we did with base-8. Let's convert 69610 to base-16. First, we find the largest power of 16 that is less than 69610. This is 162, or 296. Then:
  1. 696/162 = 2 remainder 184
  2. 184/161 = 11 remainder 8
  3. 8/161 = 8 remainder 0
We have to replace 11 with its digit representation B, and we get 2B816.
Feel free to try some more conversions for practice. You can use the application below to check your answers:

Base-2 (Binary)

On to the famous base-2, also called binary. While everyone knows binary is made up of 0s and 1s, it is important to understand that it is no different mathematically than any other base. There's an old joke that goes like this:

Can you figure out what it means?
Let's try a few conversions with base-2. First, we'll convert 1011112 to base-10. We have: 101111 = 1*25 + 1*23 + 1*22 + 1*2 + 1 = 32 + 8 + 4 + 2 + 1 = 4710.
Now let's convert 65 to binary. 26 is the highest power of 2 less than 65, so:
  1. 65/26 = 1 remainder 1
  2. 1/25 = 0 remainder 1
  3. 1/24 = 0 remainder 1
  4. 1/23 = 0 remainder 1
  5. 1/22 = 0 remainder 1
  6. 1/21 = 0 remainder 1
  7. 1/20 = 1 remainder 0
And thus we get our binary number, 1000001.
Understanding binary is super important. I've included a table below to point out digits' values.
Powers of Two
For example, the value of 10001 is 17, which is the sum of the values of the two 1 digits (16+1). This is nothing different than we have done before, its just presented in an easy to read way.




Here is a listing of the first few numbers:

decimal
(base 
10)
binary
(base 
2)

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 
16
0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
10000





Lim Zhew Sheng         B031210379





2 comments:

  1. great job.i can understand well

    ReplyDelete
  2. thanks.finally i can understand this topic.

    ReplyDelete