Professional Documents
Culture Documents
Chapter 4
Chapter 4
Before discussing numbering systems with in a computer context there are a few terms we need to
define.
1. Bit:
• Is the smallest unit of data representation.
• Is a space that can hold a single state.
2. Byte:
• Is the smallest unit of data measurement.
• Is a single group of 8 bits. [1 Byte = 8 Bits.]
3. Word:
• Is a group of 8 Bytes. [1 word = 8 Bytes.]
Decimal Number System
Z = {0,1,2,3,4,5,6,7,8,9}; B = 10
Example:
Z = {0,1}; B = 2
Example:
= 1 + 0 + 0 +8 + 16 = (25)10
Signed number representation
Here we would need to consider sign, meaning we represent both positive and negative numbers. To do
this we will first look at a method called sign and magnitude.
With this method we reserve the most significant bit of the left most bit for sign. This bit is called sign
bit.
0 Posetive
Sign Bit
1 Negative
Similar to the unsigned numbers with n bits we represent 2n numbers. The difference here is that both
positive and negative are to be represented.
Range:
Since we took 1 bit for parity we have n-1 bits left for the number.
We want to include negative as well as positive numbers and zero so our range starts from the
negative goes through zero and reaches the positive.
With these two ideas in mind our range becomes from -(2n-1-1) to 2n-1-1
Example: (11001)2
= - (1 + 0 + 0 +8) = (-9)10
Z = {0,1,2,3,4,5,6,7}; B = 8
Example:
(12403)8= 3 * 80 + 0 *81 + 4 * 82 + 2 * 83 + 1 * 84
= 3 * 1 + 0 * 8 + 4 * 64 + 2 * 512 + 1 * 4096
= (5379)10
Hexadecimal Number System
Z = (0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F}; B = 16
Example:
= (1,029,130)10
0 00 000 00 00 16 10 000 20 10
1 00 001 01 01 17 10 001 21 11
2 00 010 02 02 18 10 010 22 12
3 00 011 03 03 19 10 011 23 13
4 00 100 04 04 20 10 100 24 14
5 00 101 05 05 21 10 101 25 15
6 00 110 06 06 22 10 110 26 16
7 00 111 07 07 23 10 111 27 17
8 01 000 10 08 24 11 000 30 18
9 01 001 11 09 25 11 001 31 19
10 01 010 12 0A 26 11 010 32 1A
11 01 011 13 0B 27 11 011 33 1B
12 01 100 14 0C 28 11 100 34 1C
13 01 101 15 0D 29 11 101 35 1D
14 01 110 16 0E 30 11 110 36 1E
15 01 111 17 0F 31 11 111 37 1F
We use the method of iterated division to convert a number N10 of base 10 into a number NB of base B.
Step 1. Divide the number N10 by: whole number BN & remainder R.
127/ 2 = 63 Remainder: 1
31 / 2 = 15 Remainder: 1
15 / 2 = 7 Remainder: 1
7/2=3 Remainder: 1
3/2=1 Remainder: 1
1/2=0 Remainder: 1
Powers of 2
N 2N N 2N Note:
0 1 17 131,072
1 2 18 262,144 By looking at the power of 2, we can figure out a better
2 4 19 524,288 way of converting decimals to binary.
3 8 20 1,048,576
4 16 21 2,097,152
5 32 22 4,194,304
6 64 23 8,388,608
7 128 24 16,777,216
8 256 25 33,554,432
9 512 26 67,108,864
10 1,024 27 134,217,728
11 2,048 28 268,435,456
12 4,096 29 536,870,912
13 8,192 30 1,073,741,824
14 16,384 31 2,147,483,648
15 32,768 32 4,294,967,296
16 65,536 33 8,589,934,592
Example: Decimal to Octal (1020)10 = () 8
127 / 8 = 15 Remainder: 7
(1020)10 = (1774 )8
15 / 8 = 1 Remainder: 7
1/8=0 Remainder: 1
1020 / 16 = 63 Remainder: C
63 / 16 = 3 Remainder: F
(1020)10 = (3FC )8
3 / 16 = 0 Remainder: 3
To convert binary fractions to their decimal equivalents, all we would need to do is multiply each bit
with its power of 2 position.
= 0.7812510
Note: To convert octal and hexadecimal fractions to their decimal equivalents we follow the same steps
we used above except we change the multiplier(Base) to 8 and 16 respectively.
To convert rational numbers to their Base B fraction equivalent we will follow the following steps.
Step 2: Take number before the decimal point from the result.
To convert binary digits to their octal equivalent it’s important to answer one question.
How many binary digits are equivalent to one octal digit? ( 1 octal bit = ? binary bits)
Octal => base 8 => 8=23 hence 1 octal digit is equivalent with 3 binary digits. (1 octal bit = 3 binary bits)
So all we need to do is group each 3 binary digits and convert to its decimal equivalent.
Converting binary digits to Hexadecimal is also done in the same manner. So we will answer the same
kind of question we asked earlier, how many binary digits are equivalent to one hexadecimal digit?
Hexadecimal => base 16 => 16=24 hence 1 hexadecimal digit is equivalent with 4 binary digits.
= (5 7 2)8
= (1 7 A)16