### Unit 5: NUMBER SYSTEMS

**Key Unit Competency**By the end of the unit you should be able to:

• Compute numbers in different base systems.

• Perform arithmetic operations on binary number.**Unit Outline**

• Fundamentals of number system.

• Number base systems.

• Converting decimal to other base systems.

• Binary to other base system conversion.

• Octal to decimal conversion.

• Octal to hexadecimal conversion.

• Hexadecimal to decimal conversion.

• Decimal fraction to binary conversion.

• Binary fraction to decimal conversion.

• Negative decimal to binary conversion.

• Arthmetic operations on binary numbers.**Introduction**

In Mathematics, we represent any number using a set of ten digits ranging from 0 to 9. However, in digital computers, any type of data is represented using two voltage states “on” and “off” represented using 0 and 1. In this unit, we begin by discussing types of number systems followed by demonstrations on how to convert numbers from one system to another. Later, we take you through four binary arithmetic operations namely addition, subtraction, multiplication and division.**5.1 Fundamentals of Number Systems**

The term number system refers to a set of symbols or numeric values (numbers) used to represent different quantities. In computer science, it is important to understand number systems because the design and organisation of digital computers depends on number systems. Historically, the ten digits ranging from 0 to 9 used to express any number originated from India. Because the number of digits is ten, we refer to it as base 10 or decimal number system.

In digital computers, any type of data whether numbers, alphabets, images or sound is represented using a sequence of two digits; 0 and 1. The two digits are referred to as binary digits (bits). Because knowledge of number systems is important, we begin this section with basic concepts associated with binary and decimal numbers.**5.1.1 Bit, Byte and Nibble**

In digital computers, data is represented using a sequence of bits, bytes, nibble and

word:**• Bit:**Bit is a short form for binary digit referring to a single digit 0 or 1 used to represent any data in digital computers. In other words, a bit is the smallest unit used to represent data in digital computers.**• Byte:**A byte is a sequence of bits used to represent alphanumeric characters and

special symbols. In most cases, computers represent any type of data using a

sequence of 8 bits.**• A nibble:**A sequence of four bits representing half of a byte.

Fig. 5.1 shows an illustration that distinguishes the three terms.**5.1.2 Magnitude of Numbers**

Normally, the magnitude or weight of a digit in a number like 785 can be determined using base value (radix), absolute value, and positional (place) value.

• Base value: The base of a number also known as radix refers to the maximum number of digits used to represent a number system. For example, the number 785 falls within numbers 0 to 9 hence it is a base 10 number. When dealing with number systems, always remember to indicate the base value. For example, 4510 shows that 45 is a base 10 number.

• Absolute value: This is the face-value of a digit in a number system. For example, 5 in 785 has a face value of 5 regardless of its position in the number.

• Positional value: The positional (place) value is the position of a digit relative to other digits. For example, Table 5.1 shows the place value of 5 in 785 is ones while the digit with highest place value is 7 whose weight is 700.**Activity 5.1: Magnitude of numbers**

In groups, research in the internet how each of the digits in 485 can be interpreted in terms of base value, absolute value, and place value.**Assessment Exercise 5.1**

1. Define the following terms:

(a) bit (b) byte (c) nibble

2. Differentiate between a byte and a nibble.

3. Binary number system is fundamental to understanding how a computer works. Explain why it is important to understand the concept of number systems.

4. Using an illustrations, explain how data is represented in digital computers.**5.2 Number Base Systems**

Number systems are determined by the base representing valid digits used to represent

a number. The four types of number systems used in computing are decimal (base

10), binary (base 2), octal (base 8), and hexadecimal (base 16) number systems.**5.2.1 Decimal Number System**

Decimal number system consist of ten digits 0-9 most of us are familiar with. The prefix deci in the word decimal is a Latin word deci that means ten. Because the decimal number system has ten digits, it is also known as a base 10 or denary number system. In computing, counting of decimal numbers start from 0.**Significance of Decimal Digits**

Significance of a digit refers to its weight that is determined by its absolute and place value. In a decimal number system, the most significant digit (MSD) is the leftmost, while the least significant digit (LSD) is the rightmost digit. For a number like 7085, Table 5.2 shows that 5 is the least significant having a place of 5 while 7 is the most significant with place value of 7000.**5.2.2 Binary Number System**

Binary numbers consist of two digits – 0 and 1 referred to as binary digits, in short’

bits. In binary base system, the positional value of a number increases by powers of

two. When dealing with different number systems, always remember to indicate the

base of a binary number such as 1011_{2}.**Significance of Binary Digits**

The most significant digit (MSD) in a binary number is the leftmost digit, while the least significant digit (LSD) is the rightmost digit. For example, Table 5.3 shows that in binary number like 1011_{2}the LSD on the right has weight of 1 that is (1 × 2^{0}), while the MSD has a weight of 8.**NB:**The total weight of the binary number 10112 represents 11 in decimal numbers obtained by

adding: 8+0+2+1 = 1110

Activity 5.2: Types of number systems

Digital computers use a number system with a base of two, rather than base ten to represent any data. This is because it is much easier to engineer circuits that implement “binary number system.” In groups, discuss the four types of number systems and classify them according symbols used to represent any number. If 1011 represents 11 in decimal form, represent decimal numbers 0 to 15 in binary form.**5.2.3 Octal Number System**

The octal number system also known as octadecimal has eight digits ranging from 0 – 7 that are used to represent any number. This means that a number like 785 cannot be a valid octal number because 8 in between 7 and 5 is not within 0 to 7 digits.**Significance of Octal Digits**To get the decimal number equivalent to 7245 we add: 3584 + 128 + 32 + 5 = 3749

Thus; 7245_{8}= 3749_{10}.**5.2.4 Hexadecimal Number System**

Hexadecimal is a base 16 number system consisting of 16 digits that range from 0

to 9, and A to F. The letters A to F are used to represent numbers 10 to 15 as shown

in Table 5.5. Always remember to indicate the base of a hexadecimal number using

the subscript 16 e.g. 4F9_{16}.**Significance of Hexadecimal Digits**

In hexadecimal number system, significance of digits increases from right to left in

multiples of 16. For example, Table 5.6 shows in 946_{16}, 6 is the LSD while 9 is the

MSD with decimal place value of 2304_{10}.

The decimal equivalent of 946_{16}is obtained by adding:

2304 + 64 + 6 =2374

Thus 946_{16}= 2374_{10}.Table 5.7 below shows a summary of the four number systems classified according to

their base values:**Activity 5.3: Octal and hexadecimal number systems**

In groups of three, discuss the benefits and reasons for using octal and hexadecimal number systems.**5.3 Converting Decimal to other Base Systems**

Mathematically, it is possible to convert a number from one base system to another.

In the following section, we demonstrate how to convert decimal numbers to other

base systems.**5.3.1 Decimal to Binary Number Conversion**

To convert a decimal number to binary, there are two possible methods, the divisionremainder, and positional-value methods.**5.3.1.1 Division-by-Base Method**

In division-by-base method, a decimal number is repeatedly divided by the base until the dividend is indivisible by 2. In every division, write down the remainder on the right of the dividend. Read the sequence of 0s and 1s bottom-ups that represents the binary number. For example, to convert 45_{10}to binary form, proceed as follow:**Explanation**

1. Divide 45 by 2. We get 22 remainder 1.

2. Next divide 22 by 2. We get 11 remainder 0.

3. Continue dividing until the number is indivisible by 2. In this case, 1 is not divisible hence we write 0 remainder 1.

4. Read the remainder digits as 0s and 1s bottom up.**NB:**The remainder in the last division marked with asterisk is 1 because 1 is not perfectly divisible by 2 in the previous step. The following example demonstrates how to convert 107_{10}to binary form:**Explanation**

1. Divide 107 by 2. We get 53 remainder 1.

2. Continue dividing until the quotient is not perfectly divisible by 2.

3. Read the remainders upwards.**Activity 5.4: Converting decimals to binary form**

Using division-by base method, convert the decimal number 247 to binary form. Confirm whether is the 11110111_{2}is correct answer.**5.3.1.2 Place value Method**

The second method of converting decimal numbers to binary form is the place value method. For example, to convert 247_{10}to binary form, proceed as follows:

1. Start by writing down the place values in powers of 2 up to the value equal to or slightly larger than the number to be converted. For example, to convert 247_{10}, write down the place values up to 2^{8}, i.e. 256 as shown in Table 5.8.2. Subtract the highest place value i.e 256 from the number as shown in table 5.9.

If the difference is 0 or positive, write 1, otherwise write 0 if the difference is negative.**NB:**Note that under the place value 2^{8}, we write 0 because 247-256 returns a negative value.

3. If the difference returned a negative carry forward the number, the next lower

significant place value and calculate the difference. Since 247 – 128 returns 119 (positive), write 1 as shown in Fig. 5.10.4. Repeat the process until you encounter the least significant, until you subtract the

previous step difference from the least significant place value as shown in Table 5.11:5. Read the binary digits from left to right. This gives us 011110111. Thus: 247

_{10}= 011110111_{2}.Table 5.11 demonstrates how to use place value method to convert 107

_{10}to binary form. First, write the place values up to 128, and then calculate the difference from left to right. If the difference is > =0, insert 1 otherwise insert 0 as shown in Table 5.11.Thus: 107

_{10}=1101011_{2}**Activity 5.5: Decimal to binary conversion**

1. Using the place value method, convert the following to binary number equivalent to:

(i) 145_{10}

(ii) 1280_{10}

(iii) 5204_{10}

(iv) 8000_{10}

2. Using the place value and division by base methods convert each of the following base 10 numbers to their binary equivalents.

(a) 10_{10}(c) 43_{10}(e) 365_{10}

(b) 512_{10}(d) 143_{10 }(f) 954_{10}**5.3.2 Decimal to Octal Conversion**

To convert a decimal number to octal form, we repeatedly divide the dividend by the base value 8 until the quotient is indivisible by 8. The remainders consisting of digits between 0 and 7 are read upwards. For example, to convert 586_{10}to an octal number, proceed as follows:**Activity 5.6: Decimal to octal conversion**

Using division-remainder method, convert the following decimal numbers to octal form.

(a) 999 (b) 1875 (c) 5210 (d) 505

(e) 1810 (f) 3185 (g) 1000 750**5.4.3 Decimal to Hexadecimal Convertion**

To convert a decimal number to hexadecimal form, repeatedly divide the quotient by16 until the quotient is not divisible by the base value. The resulting remainders consisting of digits from 0-9, and A-F are read bottom-up. For example, to convert a decimal number 896 to hexadecimal form, proceed as follows:

Continue dividing until the quotient is no longer divisible by 16.

Read the remainders from bottom to top.

Thus: 896_{10}= 380_{10}**Explanation**

Divide the number by 16 and write down the quotient and the remainder. Note the remainder can be a digit between 0 and F. Taking another example let us convert a decimal 4056 to hexadecimal form.Since hexadecimal symbols between 10 and 15 are represented by letters A to F,

replace 15 with F and 13 with D in the remainders. Thus: 4056_{10}= FD8_{16}**Activity 5.7: Decimal to hexadecimal conversion**

Using division-by base method, convert the following decimal numbers to their hexadecimal equivalents:

(a) 107 (b) 9850 (c) 5207 (d) 7500 (e) 7075**5.4 Binary to other Base System Conversion**

Conversion of a binary number to other base systems is the reverse procedure to what we have covered in the previous section. In this section, we demonstrate how to convert binary numbers into decimal (base 10), octal (base 8) and hexadecimal (base 16) form.**5.4.1 Binary to Decimal Conversion**

To convert a binary number to decimal form, proceed as follows:

1. Write place values under which you place the bits from the least significant to the most significant as shown in Table 5.12. For example, Table 5.12 shows a binary number with digits placed under corresponding place values.

2. Multiply each bit by corresponding place value e.g starting with most significant e.g in case of 101101, multiply the left most bit by 32.

3. Sum the partial products to get the decimal number. In our case we add (1 × 2^{8}) + (0 × 2^{4}) + (0 × 2^{3}) + (1 × 2^{2}) + (1 × 2^{1}) + (1 × 2^{0})

This gives us:

32 + 0 + 8 + 4 + 0 + 1 = 45Therefore, 101101

_{2}= 45_{10}_{}**Activity 5.8: Binary to decimal conversion**

1. Convert 100100_{2}to decimal equivalent. Check whether the returned decimal is

9 or 36.

2. Convert 1011110_{2}to decimal form.

3. What is the decimal equivalence of 11111111_{2}?**Assessment Exercise 5.2**

Convert the following binary numbers to decimal form:

(a) 0101_{2}(b) 1111_{2}(c) 10101101110_{2}

(d) 10111111_{2}(e) 1011001_{2}(f) 111000111_{2}**5.4.2 Binary to Octal Conversion**

To convert a binary to Octal system group the One’s (1’s) and zero’s(0’s) into sets of three bits starting from right to left. The reason for grouping into 3 bits is because the maximum octal digit (7) has a maximum of 3 digits as shown in Table 5.13._{}_{}For example, to convert 11010001

_{2}to octal format, proceed as follows

1. Group the bits to sets of 3 starting from right.

2. Write down the octal digit represented by each set of bits as shown in Table 5.14:_{}_{}Thus: = 011010001

_{2}≡ 321_{8}**Assessment Exercise 5.3**

Convert the following binary numbers to Octal form.

(a) 10100100 (b) 10100111 (c) 1110010

(d) 101110101 (e) 10010010 (f) 11011111000

(g) 1100001011 1011011001 (i) 110011100111

(j) 100110110101011**5.4.3 Binary to Hexadecimal Conversion**

Similar to the approach used with octal number system, a binary number can be converted to hexademal format by grouping the bits to a set of 4 bits. This is because the largest hexadecimal digit i.e. F(15) has 4 bits as shown in Table 5.15:_{}_{}_{}For example, to convert 11010001

_{2 }to hexadecimal form, group the bits into sets of 4 starting

from right to left as follows: as shown in Table 5.16:_{}_{}Thus: = 1101 0001

_{2}= D1

If a binary number does not have an exact set of 4 bits after grouping such as 1100100001,

proceed as follows:

1. Split the number into sets of 4 bits starting from right to left. In our case, we get

three complete sets and one incomplete one: 11 0010 0001

2. Because the leftmost set has two bits, add two zeros to it on the left to get: 0011 0010 0001

3. Using the binary equivalents in Table 5.17, place each the equivalent hexadecimal

digit under each of the set of bits._{}_{}Thus: 0011010001

_{2}= 321_{16}**Activity 5.9: Binary to hexadecimal conversion**

1. Convert 10111100110^{2}to its hexadecimal equivalent.

2. Convert the binary number 111011011^{2}to hexadecimal form.

3. Find the hexadecimal equivalence of 110111^{2}.

4. Convert the binary number 0101110^{2}to hexadecimal form._{}**Assessment Exercise 5.4**

1. Convert the following hexadecimal numbers to their binary equivalents:

(a) 1010010101_{2}(b) 1001000111_{2}(c) 111011111101

(d) 100100000111_{2}(e) 101110101101 (f) 1100101111011111

(g) 101100001011100 1010101111001101 (i) 1010101110000111010**5.5 Octal to Decimal Conversion**

To convert octal numbers to decimal form, we use the division-by-base and place value methods used on binary numbers. For example, to convert 512_{8}to decimal form, proceed as follows:

1. Write each number under base 8 place value as shown in Table 5.18:_{}_{}2. From left to right, multiply each digit by its place value as shown below:

_{}_{}**Assessment Exercise 5.5**Convert the following octal numbers to decimal form.

(a) 77_{8}(b) 64_{8}(c) 102_{8}(d) 1200_{8}(e) 1000_{8}

(f) 173_{8}(g) 123_{8}777_{8}(i) 345_{8 }(j) 166_{8}**5.6 Octal to Hexadecimal conversion**

Because octal to hexadecimal conversions cannot be done directly, we first convert

given octal numbers to its decimal or binary equivalent. In the second step we convert the decimal or binary number to its hexadecimal equivalent.

1. To start with, we demonstrate how to use the two-stage approach to convert an octal number 1002_{8}to hexadecimal:

1002_{8}= (1 × 8^{3}) + (0 × 8^{2}) + (0 × 8^{1}) + (2 × 8^{0})

= 1 × 512 + 0 × 64 + 0 × 8 + 2 × 1

= 512 + 0 + 0 + 2

2. Convert the decimal number 514 to hexadecimal using division-by-base method.:Alternatively, you can convert an octal number to hexadecimal by converting the number to binary form as follows:

1. Convert each octal digit to a 3-bit binary number as shown in Table 5.19 below:2. Convert the resulting binary number i.e. 001000000010

_{2}to hexadecimal by grouping the bits into four groups starting from right:

3. Write down the hexadecimal equivalent of each of the 4-bit grouping as shown below:Therefore, 0010 0000 00100

_{2}= 202_{16}**5.7 Hexadecimal to Decimal Conversion**

To convert a hexadecimal number to base ten equivalent, proceed as follows:

1. First, write the place values starting from the right hand side.

2. If a digit is a letter such as an ‘A’ write its decimal equivalent.

3. Multiply each hexadecimal digit with its corresponding place value, and then add the partial products.

The following example illustrate how to convert 111_{16}to decimal form:

1. Write each digit under its place value as shown in Table 5.21.2. Multiply each hexadecimal digit with corresponding places value and write down

the partial products (256 × 1) + (16 × 1) + (1 × 1) downwards as follows:3. Add the partial products: 256 + 16 + 1 = 273

Thus: 111_{16}= 273_{10}

Taking another example, let us convert A9_{16}to decimal form:(i) Write each bexadecimal digit under its place value.

(ii) Add the partial products (16 × 10) + (1 × 9)

This gives us 160 + 9 = 169_{0}

Thus: A9_{16}= 169_{10}**Assessment Exercise 5.6**

Convert the following hexadecimal numbers to decimal form:

(a) 32_{16}(b) CCD_{16}(c) EFE_{16}(d) 119_{16}(e) 328_{16}

(f) ABD_{16}(g) 10AFFD_{16}DDFF34_{16}(i) 11ABDF_{16}(j) CDFF31_{16}**5.8 Decimal Fraction to Binary Conversion**

In mathematics, a number with integer and fractional parts such as 87.25 is known as

a real number. In computing, a real number is referred to as floating point number.

The fractional part has a value that is less than 1 written as 1/x or 0.x. For example,

87.25 has a fractional part 0.25 that may also be written as 1/4. The weight of a

floating point number increases from right to left as shown in Table 5.23:In computing, the same approach is used to represent fractional binary numbers.

For example, the fractional binary number 11.11011_{2}may be represented as shown

in Table 5.24.For example, to convert a number like 87.25 to binary form, first convert the integer

part using one of the methods discussed earlier. Then, convert the fractional part as

follows:

1. Start by multiplying the fractional part by 2 and write the partial product. For

example, 0.25 × 2 = 0.5.

2. Take the fractional part of the previous partial product and multiply it by 2. In

our case: 0.50 × 2 = 1.000.

3. Repeat until the fractional part on the right of decimal point of the partial product

is 0 or starts recurring. For example, in step 2 above, the fractional part is 000

hence we stop.

4. Read downwards the 0s and 1s on the left of the decimal point of partial products

as shown below:To convert a floating point decimal number 7.375, proceed as follows:

1. Convert the integer part 7 using the division-by 2 or place value method. The

operation should return 111.

2. Convert the fractional part until the part on the right of decimal point is 0 or starts

recurring:3. Read the digits on the left of decimal point downwards as shown by the arrow.

In this case, the digits are 0.011.

4. Combine the integer and fractional parts to get: 111+0.011= 111.011_{2}Thus: 7.375_{10}= 111.011_{2}

In this example, we demonstrate how to convert a decimal number 0.40 that returns

a recurring binary fraction. We proceed as follows:**Activity 5.10: Decimal fraction to binary conversion**

1. Convert the decimal number 43.5625_{10}to binary form. Compare your answer with

101011.1001_{2}.

2. Convert the following floating point decimal numbers to binary form:

(a) 0.625_{10}(b) 0.450_{10}(c) 2.500_{10}

(d) 5.1625_{10}(e) 7.1875_{10}(f) 0.350_{10}**5.9 Binary Fraction to Decimal Conversion**

To convert a floating point binary number like 11.011_{2}to decimal form, proceed as follows:

1. Convert the bits on the left of the decimal point into decimal form and sum-up the partial products as follows:2. Next, convert the bits on the right of the decimal point to decimal form using

corresponding place values from left to right as shown below:3. Finally, add the two decimal parts: 3.000

_{10}+ 0.375_{10}= 3.375_{10}

Thus: 11.011_{2}= 3.375_{10}**Activity 5.11: Binary fraction to decimal conversion**

Convert 11.11011_{2}to decimal form and compare the value you get with 3.84375_{10}.**Assessment Exercise 5.7**

1. Convert the following binary numbers to decimal form:

(a) 0.10011_{2}(b) 0.0010_{2}(c) 0.10101_{2}

(d) 11.0110_{2}(e) 101.11110_{2}(f) 100.110_{2}**5.10 Negative Decimal to Binary Conversion**

Conversion of negative decimal numbers to binary form is simplified by use of one’s

complement and two’s complement. One’s complement is a value obtained by inverting

each bit in a binary number while two’s complement is value obtained by adding 1

bit to one’s complement. In this section, we show how to use one’s complement and

two’s complement to convert a negative decimal number to binary form.**5.10.1 Ones complement**

One’s complement is a temporary step to finding twos complement of a binary number. To convert a binary number to ones complement, we invert 0 bits to 1s and vice versa. For example, the one’s complement of 10011102 may be expressed as a unary operation as follows:

~(1001110) = 0110001; where ~ stands for negation.**Activity 5.12: One’s complement**

Represent the following binary numbers to ones complement. In each case, state the decimal number represented by the ones complement.

(a) 1101001_{2}(b) 1111010_{2}(c) 10101101_{2}

(d) 1011111_{2}(e) 1011001_{2}(f) 11100111_{2}**5.10.2 Two’s complement**

Twos complement is another method used to represent negative numbers in binary form. Two’s complement of a number is obtained by getting the one’s complement then adding 1 bit.

For example, to find the two’s complement of the binary number 10011102, proceed as follows:

1. Convert 1001110 to one’s complement using unary operator (~) :

~(1001110) = 0110001;2. Add 1 bit to one’s complement to get the two’s complement:

0110001 + 1 = 0110010

Thus: Two’s complement of 1001110 = 0110010.

Taking another example, let us convert the decimal number 45 to binary form and express its negative value using twos complement.

The problem requires that you pad (insert) 0 bits to the left of the most significant bit

until the number has 8 bit. To get the 2s complement, proceed as follows:

1. 45_{10}to 8-bit binary form i.e 00101101_{2}.

2. Convert the binary number to one’s complement as follows:

~(00101101) = 11010010.

3. Add 1 to one’s compliment number as follows:

11010010 + 1 = 11010011.**Activity 5.13: One’s and two’s compliment**

1. In decimal number system, we may represent integers using nine’s complement while in binary, we use ones and twos complement. In groups, perform the following activities:

• Demonstrate how you would represent nines complement of decimal number like 945. Explain why this complementation is rarely used in computer processing logic.

• Explain the difference between ones and twos complement and demonstrate how you would represent a binary number like 11010010_{2}using twos complement.

2. Convert the following negative decimal numbers to binary equivalent using one’s

and two’s complement:

(a) -20 (b) -55 (c) -108 (d) -586**5.11 Arithmetic Operations on Binary Numbers**

Basic arithmetic operators such as addition(+), subtraction(–), multiplication (×), division(/) can be used to manipulate binary numbers. In computers, these operations are performed inside the central processing unit by arithmetic and logic unit (ALU). Because, ALU only performs binary addition, subtraction operation is carried out using one’s or two’s complements. To perform multiplication and division, the ALU shifts the bits to the left or right before adding the operands.**5.11.1 Binary addition**

The four rules applied in binary additions are:For example, to calculate binary addition 111 + 011, proceed as follows:

1. Arrange the bits vertically, and then add them from right to left like in decimal

numbers as shown below:2. Start the add operation with the least significant digits on the right.

1_{2}+ 1_{2}= 10_{2}(write 0, and then carry 1)

3. Add the carry over digit from the previous step to the second least significant bit

to get:

1_{2}+ 1_{2}+ 1_{2}= 11_{2}(write 1, and then carry 1)

4. Finally, add the most significant bits, plus the carry over from the previous step

to get:

1_{2}+ 0 + 1_{2}= 10_{2}, (write 10 because to this is is the leftmost)

Thus: 111_{2}+ 011_{2}= 1010_{2}

The four steps are summarized in Table 5.25 below:**Activity 5.14: Binary addition**

Workout binary addition of 00110_{2}and 01101_{2}. Check if 100011 shown in Table 5.26

is the correct sum.**Activity 5.15: Binary addition**

Find the sum of the following binary numbers:To find the sum of the three numbers, first add the two numbers, then add the partial

sum to the third number as follows:**Assessment Exercise 5.8**

Work out the following binary additions:**5.11.2 Binary subtraction**

The four rules applied in binary subtraction are:The following example illustrate binary subtraction using direct method:

Starting from right to left, work out binary subtraction as follows:

**Activity 5.16: Binary subtraction**

Work out the following the binary difference:

(a) 10011_{2}– 1100_{2}(b) 10110 – 1011

(c) 101 – 100 (d) 10111 – 1111**Assessment Exercise 5.9**

Work out the following binary subtractions:

1. 11 001 2. 101 3. 11011 4. 1100 5. 111011

– 1 010 – 100 – 111 – 011 – 1106. 100010 – 11 7. 01101 – 1011 8. 11111111 – 10101101

9. 11101101 – 100111 10. 100000 – 1111**Subtraction using one’s complements**

Because a computer does not perform direct subtraction, one’s complement is an

alternative method used to find the difference of numbers. For example, to compute

5-3 using the ones complement, proceed as follows:

1. Rewrite the problem as 5 + (–3) to show that a computer performs subtraction

by adding 5 to ones complement of the decimal 3.

2. Convert the decimal number 3 to its 8-bit number, i.e., 00000011_{2}.

3. Convert 000000112 to ones complement, i.e., 11111100_{2}.

4. Convert the first operand i.e 5 from decimal to binary form. This gives us 00000101

in 8-bits.

5. Add the two binary numbers as shown below.**NB:**We observe that the difference between the two numbers has nine bits instead

of the original 8. This extra bit is known as the overflow bit.Therefore, the result shows that the difference between 5 and 3 is 00000001; but

this is not true because the answer should be 00000010.

6. To get the correct answer, add the overflow bit back to the difference.

Thus the correct difference is:

00000001 + 1 = 00000010.**Activity 5.17: Subtraction using ones compliments**

Using 8 bits, find the ones complement of the negative decimal number -13_{10}.

1. Convert the absolute value 13_{10}to an 8-bit binary number, 00001101.

2. Negate each bit such that zeros becomes 1’s and ones becomes 0’s to get

11110010_{2}. This represents -13 in binary form.**Subtraction using twos complements**

Like in one’s complement, the two’s complement of a number is obtained by negating

a positive number to negative number. For example to get the difference 5 – 3, using

the two’s complement, proceed as follows:

1. Rewrite the expression as addition of 5 + (–3).

2. Convert the absolute value of 3 into 8-bit binary equivalent i.e. 00000011.

4. Take the one’s complement of 00000011, that is 11111100.

5. Add 1 to the one’s complement i.e. 11111100+1 to get 11111101.

6. Convert 5 to binary and add it to two’s complement of 3 as follows:**NB:**After adding the two numbers, the sum becomes a nine bit number. But because a computer can handle only 8 bits, the extra bit on the extreme left (most)

significant digit is referred to as overflow bit.

7. The bit in brackets is an overflow hence it should be ignored. Therefore, the

correct difference is 00000010.**Activity 5.18: Subtraction using two’s complement**

1. In terms of memory management, explain why an overflow bit resulting from

arithmetic operations is always discarded.

2. Using two’s complement, find the difference between the following decimal

numbers:

(a) 31-17 (b) 27-5

(c) 127-50 (d) 17-35**5.11.3 Binary Multiplication**

The pen-and-paper method of binary multiplication is quite similar to that used in

decimal numbers only that the multipliers are 0s and 1s. In binary multiplications,

the four rules applied from right to left are:For example, to perform binary multiplication 1011 x 101, proceed as follows:

**Explanation**

1. Multiply the first multiplication with each digit of the second multiplication.

2. Shift the partial products to the left.

3. Add the partial products as follows:

1011 + 0000 + 1011 = 110111_{2}**Activity 5.19: Binary Multiplication**

Perform the following binary multiplications:

(a) 101101 x 110

(b) 101101 x 111

(c) 1011.01 x 110.1**5.11.4 Binary Division**

Binary division is a shift and subtract operation. In each step, the dividend is grouped

into bits which are divisible by the divisor, and then subtracted. For example, to

perform division of 10101_{2}÷ 11_{2}proceed as follows:**Explanation**

1. Group the dividend into bits divisible by the divisor starting from left to right,

and then subtract.

2. Write down the quotient and the divisor from the dividend.

3. Drop down the next digit and check if the dividend is divisible by the divisor.

4. Continue until the resulting dividend is zero or not divisible.

Taking another example of binary division, let us workout 11100110÷110.Therefore, 11100110÷110 = 100110 remainder 10

**Activity 5.20: Binary division**

Perform the following binary divisions:

(a) 1011 ÷ 11 (b) 10011 ÷ 101 (c) 1111 ÷ 11 (d) 11 ÷ 11**Assessment Exercise 5.10**

1. Convert the decimal number –7 to an 8-bit binary number using twos complement.

2. Using 16-bit word, find the two’s complement of the following decimal numbers:

(a) –31_{10}(b) –28_{10}(c) –5_{10}

3. Convert the following expressions to binary form and perform the operations

using one’s and two’s complement.

(a) 14 – 7 (b) 28 – 12 (c) 34 – 33 (d) 100– 50**Unit Test 5**

1. Differentiate between the following number systems:

(a) Octal and decimal number system.

(b) Binary and hexadecimal number systems.

2. Convert the following binary numbers to decimal form:

(a) 101110_{2}(b) 101011_{2}(c) 0110_{2}

3. Convert the following decimal numbers to binary form:

(a) 789_{10}(b) 570_{10}(c) 42_{10}

4. Calculate the sum of the following binary expressions:

(a) 1110_{2}+ 1111_{2}(b) 001_{2}+ 100_{2}(c) 1101_{2}+ 1011_{2}+ 100_{2}

5. Using ones and twos complement, workout the following arithmetic:

(a) 11001 – 1101 (b) 1000 – 101 (c) 100011 – 111

(d) 10101110 – 100110 (e) 10100110 – 101 (e) 111011 – 101

6. Using one’s and two’s complement, convert the following decimal numbers to

binary form:

(a) – 75_{10}(b) – 80_{10}(c) –100_{10}

7. Determine the value of k in the following binary arithmetic operations:

(a) 100110 – k = 001010_{2}

(b) k × 1101_{2}= 1000001_{2}

8. Work out the decimal equivalents of the following binary numbers:

(a) 0.10010 (b) 101.11 (c) 11.101 (d) 0.001

9. Find binary equivalents of the following decimal numbers:

(a) 0.35 (b) 2.50 (c) 65.20 (d) 17.125