Chapter 6: Base Numbers: 6.1 Number Conversion
Chapter 6: Base Numbers: 6.1 Number Conversion
Chapter 6: Base Numbers: 6.1 Number Conversion
There is much other numbering system - mostly associated with computers. These include:
1. Binary Octal
2. Hexadecimal
3. Binary Coded Decimal (BCD)
This is the system in everyday use; there are 10 digits (0 to 9 inclusive) so it has a 'base' of 10.
Example:
1. Taking the number 7213, it can be written as:
Let's look at base-two, or binary, numbers. How would you write, for instance, 1210 as a binary
number? You would have to convert to base-two columns, the analogue of base-ten columns. In
base two, you have 20 = 1, 21 = 2, 22 = 4, 23 = 8, 24 = 16, and so forth. The first column in base-two
math is the units column. But only "0" or "1" can go in the units column. When you get to "two",
you find that there is no single solitary digit that stands for "two" in base-two math. Instead, you put
a "1" in the twos column and a "0" in the units column, indicating "1 two and 0 ones". The base-ten
"two" (210) is written in binary as 102.
1
UNIVERSITI KUALA LUMPUR
MALAYSIAN INSTITUTE OF AVIATION TECHNOLOGY
Here is a listing of the first few numbers:
Decimal Binary
(base 10) (base 2)
0 0 0 ones
1 1 1 one
2 10 1 two and zero ones
3 11 1 two and 1 one
4 100 1 four, 0 twos, and 0 ones
5 101 1 four, 0 twos, and 1 one
6 110 1 four, 1 two, and 0 ones
7 111 1 four, 1 two, and 1 one
8 1000 1 eight, 0 fours, 0 twos, and 0 ones
9 1001 1 eight, 0 fours, 0 twos, and 1 one
10 1010 1 eight, 0 fours, 1 two, and 0 ones
11 1011 1 eight, 0 fours, 1 two, and 1 one
12 1100 1 eight, 1 four, 0 twos, and 0 ones
13 1101 1 eight, 1 four, 0 twos, and 1 one
14 1110 1 eight, 1 four, 1 two, and 0 ones
15 1111 1 eight, 1 four, 1 two, and I one
16 10000 1 sixteen, 0 eights, 0 fours, 0 twos, and 0 ones
Converting between binary and decimal numbers is fairly simple, as long as you remember that each
digit in the binary number represents a power of two.
Example
List the digits in order, and count them off from the RIGHT, starting with zero:
Digits : 101100101
Numbering : 876543210
Use this listing to convert each digit to the power of two that it represents:
2
UNIVERSITI KUALA LUMPUR
MALAYSIAN INSTITUTE OF AVIATION TECHNOLOGY
2. Convert 35710 to the corresponding binary number. To do this conversion, you need to
divide repeatedly by 2, keeping track of the remainders as you go. Watch below:
As you can see, after dividing repeatedly by 2, I ended up with these remainders
2 357
2 178 R1
2 89 R0
2 44 R1
2 22 R0
2 11 R0
2 5 R1
2 2 R1
2 1 R0
2 0 R1
These remainders tell us what the binary number is. Read the numbers from around the
outside of the division, starting on bottom and wrapping your way around the right-hand
side.
An older computer base system is "octal" or base-B number system. The digits in octal are
0,1,2,3,4,5,6 and 7. The value "eight" is written as 1 eight and 0 ones or 108
Example:
8 359
8 44 R7
8 5 R4
8 0 R5
3
UNIVERSITI KUALA LUMPUR
MALAYSIAN INSTITUTE OF AVIATION TECHNOLOGY
OCTAL TO DECIMAL CONVERSION
Method used: sum the digits after each has been multiplied by its associated weight
Example:
Base 8 82 81 80
Decimal 2 3 7
Method used: replace each octal digit with the appropriate three-bit binary number
Method use: Break the binary digits into groups of three from right/decimal point and convert each
group into its appropriate octal digit.
thus, (010111)2=(27)8
4
UNIVERSITI KUALA LUMPUR
MALAYSIAN INSTITUTE OF AVIATION TECHNOLOGY
6.1.4 Hexadecimal System
Hexadecimal describes a base-16 number system. The hexadecimal numbers are 0-9 and then use
the letters A-F. We show the equivalence of binary, decimal, and hexadecimal numbers in the table
below.
Solution :
16 1234
16 77 R2
16 4 R13 = D
16 0 R4
5
UNIVERSITI KUALA LUMPUR
MALAYSIAN INSTITUTE OF AVIATION TECHNOLOGY
HEXADECIMAL TO DECIMAL CONVERSION
Method use: sum the digits after each has been multiplied by its associated weight
Solution :
162 161 160
4 D 2
Example:
Solution: F = 1111
8 = 1000
6
UNIVERSITI KUALA LUMPUR
MALAYSIAN INSTITUTE OF AVIATION TECHNOLOGY
2. Convert 111010110102 to Hexadecimal
Solution: Break the binary digits into groups of four from right/decimal point and
convert each group into its appropriate hex digit
7 5 A
Arithmetic in binary is much like arithmetic in other numeral systems. Addition, subtraction,
multiplication, and division can be performed on binary numerals.
6.2.1 Addition
The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is
relatively simple:
0+0 0
0+1 1
1+0 1
1+1 0, carry 1 (since 1 + 1= 0 + 1 x 10 in binary)
Adding two "1" digits produces a digit "0", while 1 will have to be added to the next column. This is
similar to what happens in decimal when certain single-digit numbers are added together; if the
result equals or exceeds the value of the radix (10), the digit to the left is incremented
This is known as carrying. When the result of an addition exceeds the value of a digit, the procedure
is to "carry" the excess amount divided by the radix (that is, 10/10) to the left, adding it to the next
positional value. This is correct since the next position has a weight that is higher by a factor equal to
the radix. Carrying works the same way in binary.
7
UNIVERSITI KUALA LUMPUR
MALAYSIAN INSTITUTE OF AVIATION TECHNOLOGY
Example
1 1 1 1 1 (carried digits)
0 1 1 0 1
+ 1 0 1 1 1
= 1 0 0 1 0 0
In this example, two numerals are being added together: 011012 (13-decimal) and 101112 (23
decimal). The top row shows the carry bits used. Starting in the rightmost column, 1 + 1= 102. The 1
is carried to the left, and the 0 is written at the bottom of the rightmost column. The second column
from the right is added: 1 + 0 + 1 = 102 again; the list carried and is written at the bottom. The third
column: 1 + 1 + 1 =112. This time ,a 1 is carried, and a 1 is written in the bottom row. Proceeding like
this gives the final answer 1001002 (36 decimal)
6.2.2 Subtraction
Subtracting a "1" digit from a "0" digit produces the digit 1, while 1 will have to be subtracted from
the next column. This is known as borrowing. The principle is the same as for carrying. When the
result of a subtraction is less than 0, the least possible value of a digit, the procedure is to "borrow"
the deficit divided by the radix (that is, 10/10) from the left, subtracting it from the next positional
value.
Example
* * * * (carried digits)
1 1 0 1 1 1 0
- 1 0 1 1 1
= 1 0 1 0 1 1 1
Subtracting a positive number is equivalent to adding a negative number of equal absolute value;
computers typically use two's compliment notation to represent negative values' This notation
eliminates the need for a separate "subtract" operation. A - B = A + not B +1
6.2.3 Multiplication
Multiplication in binary is similar to its decimal counterpart. Two numbers A and B can be multiplied
by partial products: for each digit in B, the product of that digit-in A is calculated and written on a
new line, shifted leftward so that its rightmost digit lines up with the digit in B that was used. The
sum of all these partial products give the final result.
8
UNIVERSITI KUALA LUMPUR
MALAYSIAN INSTITUTE OF AVIATION TECHNOLOGY
Since there are only two digits in binary, there are only two possible outcomes of each partial
multiplication:
Example
1. For example, the binary numbers 1011 and 1010 are multiplied as follow:
1 0 1 1 (A)
x
1 0 1 0 (B)
0 0 0 0
+ 1 0 1 1 Corresponds to a zero in B
+ 0 0 0 0 Corresponds to a one in B
+ 1 0 1 1
= 1 1 0 1 1 1 0
2. Binary numbers can also be multiplied with bits after a binary point:
6.2.4 Division
1 0 1 1 1 0 1 1
Here, the divisor is 1012, or 5 decimal, while the dividend is 110112, or 27 decimal. The procedure is
the same is that of decimal long division; here, the divisor 1012 goes into the first three digits 1102 of
the dividend one time, so a "1" is written on the top line. This result is multiplied by the divisor, and
subtracted from the first three digits of the dividend; the next digit (a "1") is included to obtain a
new three-digit sequence:
9
UNIVERSITI KUALA LUMPUR
MALAYSIAN INSTITUTE OF AVIATION TECHNOLOGY
Example
1
1 0 1 1 1 0 1 1
- 1 0 1
0 1 1
The procedure is then repeated with the new sequence, continuing until the digits in the dividend
have been exhausted.
1
1 0 1 1 1 0 1 1
- 1 0 1
0 1 1
- 0 0 0
1 1 1
- 1 0 1
1 0
Thus, the quotient of 110112 divided by 1012 is 1012, as shown on the top line, while the remainder,
shown on the bottom line, is 102. ln decimal, 27 divided by is 5, with a remainder of 2.
10
UNIVERSITI KUALA LUMPUR
MALAYSIAN INSTITUTE OF AVIATION TECHNOLOGY
EXERCISE/ASSIGNMENT:
11