0% found this document useful (0 votes)
27 views10 pages

CSC 207-Lecture Note 33

Uploaded by

adedavidhishere
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views10 pages

CSC 207-Lecture Note 33

Uploaded by

adedavidhishere
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

FEDERAL UNIVERSITY OYE-EKITI

DEPARTMENT OF COMPUTER SCIENCE

CSC 207: INTRODUCTION TO DIGITAL COMPUTER SYSTEMS

UNIT: 2

LECTURERS IN CHARGE

DR. AWOYEMI

MRS AFOLALU

LECTURE 3:

BODH TABLE
BINARY ARITHMETIC OPERATIONS

Consider the binary number 10100.

10100 = (1 x 24) + (0 x 23) + (1 x 22) + (0 x 21) + (0 x 20)

= 16 + 0 + 4 + 0 + 0

= 20

Binary –decimal Conversion

101 = 1 x 22 + 0 x 21 + 1 x 20

=4+0+1

=5

1010 = 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20

=8+0+2+0

= 10

1111 = (1 x 23)+ (1 x 22)+ (1 x 21)+ (1 x 20)

=8+4+2+1

= 15

1.01 = 1 x 20 + 0 x 2-1 + 0 x 2-2 + 1 x 2-3


= 1 + 0 + 0 + .125
= 1. 125

Decimal – binary Conversion

Convert 14.12510 to Base2


The number is written from below, that is 1110. So the binary equivalent of 14 is
1110. If the decimal number has a fractional part, then the fractional part is
converted into binary by multiplying it with 2. Only the integer of the result is
noted and the fraction is repeatedly multiplied by 2 until the fractional part
becomes 0. This can be explained using the following example.

Here the number is written from top - .001. So the binary equivalent of 0.125 is
.001

Therefore, from the above two examples, we can conclude that the binary
equivalent of the decimal number 14.125 is 1110.001.

Binary Addition

The addition of numbers in the binary system is shown in the table 5.2 and is
illustrated by the

examples.
EXAMPLE 1:

The addition of 101101 and 1111 (which are 45 and 15 in the decimal system ) is
as follows:

EXAMPLE 2:

The addition of 1111011 and 11011( which are 123 and 27 in the decimal system )

BINARY SUBTRACTION

Subtraction rule

0–0=0
1–0=1
1- 1=0
0 - 1 = 1 borrow 1
EXAMPLE 1:

The subtraction of 1111 from 101101 (which are 15 and 45 in the decimal system)

EXAMPLE 2: subtraction of 11011 from 1111011(which are 27 and 123 in the


decimal system)
When you are subtraction a larger number from a smaller number, the result
obtained will be the 2’s complement. If we subtract 45 (101101) from 15 (1111),
we should get –30. But when we do the binary subtraction, instead of getting -
11110 (-30) we will get the 2’s complement of 11110 which is 10.

BINARY MULTIPLICATION
Table of Basic Rules for Binary Multiplication
0×0=0
0×1=0
1×0=0
1×1=1
The multiplication process for binary numbers is similar to that for decimal
numbers. Partial products are formed, with each product shifted one place to the
left. This is illustrated below.
Example 7 Multiply 710 = 111 and 510 = 101 in binary form.

solution

111
×101
111
0000
+1 1 1 0 0
100011
The third row is the multiplication of 111 by 1. In the fourth row, the 0 is
the shift left before 111 is multiplied by 0. In the fifth row, the 00 is the shift left
before 111 is multiplied by 1. The final row is the binary sum of the preceding
three rows.

BINARY DIVISION
Binary division follows a similar process to that of decimal division.

Division Rule
0–0=0
1–0=1
1- 1=0
0 - 1 = 1 borrow 1
Example 8:
Divide (a) 1510 by 510 in binary form, and (b) 1510 by 610 in binary form.

The process for each of these is shown below.

In decimal form, 1510 ÷ 510 = 310,


and 3110 is 11 in binary, which is the answer in the left hand array.

In decimal form, 1510 ÷610 = 2.510, and 2.510 is 10.1 in binary,


Which is the answer in the right hand array.

COMPLEMENTS

Computers use complemented numbers or complements to perform subtraction.


In the binary number system there are two types of complements – 1’s
complement and 2’s complement. Similarly, in the decimal number system also
their two types of complements-9’s complement and the 10’s complement.

DECIMAL COMPLEMENTS

1) 9’s Complement: The 9’s complement of a decimal number is obtained by


subtracting each digit of the number from 9.
Example 1: 9’s complement of 2 is
9-2=7
Example 2: 9’s complement of 123 is
999-123=876
2) 10’s Complement: The 10s complement of decimal number is obtained by
adding 1 to 9’s complement of that number.

Example 1: 10’s complement of 2 is

9 - 2= 7 + 1 = 8
Example 2: 10’s complement of 123 is

999 – 123 = 876 + 1= 877

BINARY COMPLEMENTS

1. 1’s Complement

To get the 1’s complement at a number replace 0 by 1 & 1 by 0.


Example 1:, the 1’scomplement of 1010 is 0101,
Example 2: the 1’s complement of 1111 is 0000

2. 2’s Complement

To get the 2’s complement of a number, add 1 to the 1’s complement of the
number.
Example 1: the 2’s complement of 1010 is 0110,
Example 2: the 2’s complement of 1111 is 0001,

0000
1111
1
100 0 0
Just as adding a number to the 10’s complement of another number is equivalent
to subtraction the second number from the first in the decimal system, adding a
number to the 2’s complement of another number is equivalent to subtracting the
second number from the first in the binary system.

SIGNED AND UNSIGNED NUMBER EPRESENTATIONS

We put a plus (+) or minus (-) sign before the number to represent its sign. In
computers such notations cannot be employed and therefore, a different method is
used. To represent a positive number a 0 is placed before the binary number.
Similarly, to represent a negative number, a 1 is placed before the binary number.

Example: +15 and -15 are represented by 01111 and 11111 respectively.

There is only one way to represent a positive number, but there are different ways
to represent a negative number.

These are:

Signed – magnitude representation

Signed – 1’s complement representation

Signed – 2’s complement representation

The number 15 can be represented in the above three ways as 11111, 10000 and
10001 respectively. Since 15 is represented by 4 bits and a separate bit is used to
represent sign, in a computer, the most significant bit (MSB) can be used to
represent the sign of the number.

For example, 8-bit computers will represent- 15 as 10001111, 10000000 and


10000001 for signed-magnitude, signed -1’s complement and signed-2’s
complement respectively. 7 bits are used to represent the number and the MSB is
used to represent the sign of the number.

When all the bits of the computer word (in an 8-bit computer, the length of a word
is 8 bits) are used to represent the number and no bit is used for sign
representation, it is called unsigned representation of numbers

FIXED AND FLOATING POINT REPRESENTATION


In ordinary arithmetic, a negative number is indicated by a minus sign and a
positive number by a plus sign. Because of hardware limitations, computers must
represent everything with 1’s and 0’s including the sign of a number.

It is customary to represent the sign with a bit placed in the leftmost position of
the number. The convention is to make the sign bit equal to 0 for positive and 1 for
negative.

There are two ways of specifying the position of binary point (or decimal point)

in a register:

1. Fixed Position Representation

Binary point is fixed e.g. 1101101.0001001

2. Using Floating Point Representation

Binary point floats to the right of the most significant 1 and an exponent is used
e.g. 1.1011010001001 * 26

Fixed Point Numbers:

The binary point is not a part of the representation but is implied. The number of
integer and fraction bits must be agreed upon by those generating and those
reading the number.

e.g. Fixed point representation using 4 integer bits and 3 fraction bits:

0110110 will be interpreted as 0110.110.

Floating-Point Representation:

The floating point representation of a number has two parts:

The first part represents a signed, fixed-point number called the mantissa.

The second part designates the position of the decimal (or binary) point and is
called the exponent.

The fixed point mantissa may be a fraction or an integer.

Floating point is always interpreted to represent a number in the following


form:

m * re
MANTISSA is the part of a logarithm to the base ten that is to the right of the
decimal point.

Example:
if 2.749 is a logarithm,
. 749 is the mantissa.

The decimal number +6132.789 is represented in floating point with a fraction and
an exponent as follows:

Fraction Exponent +0.6132789 +04

This representation is equivalent to the scientific notation

+0.6132789 * 10+4

You might also like