CSC 207-Lecture Note 33
CSC 207-Lecture Note 33
UNIT: 2
LECTURERS IN CHARGE
DR. AWOYEMI
MRS AFOLALU
LECTURE 3:
BODH TABLE
BINARY ARITHMETIC OPERATIONS
= 16 + 0 + 4 + 0 + 0
= 20
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
=8+4+2+1
= 15
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)
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.
COMPLEMENTS
DECIMAL COMPLEMENTS
9 - 2= 7 + 1 = 8
Example 2: 10’s complement of 123 is
BINARY COMPLEMENTS
1. 1’s Complement
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.
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:
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.
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
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:
Binary point floats to the right of the most significant 1 and an exponent is used
e.g. 1.1011010001001 * 26
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:
Floating-Point Representation:
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.
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:
+0.6132789 * 10+4