0% found this document useful (0 votes)
26 views

SLM - Unit 03

Uploaded by

pavanmay227597
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

SLM - Unit 03

Uploaded by

pavanmay227597
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Fundamentals of Information Technology Unit 3

Unit 3 Number Systems and Boolean Algebra


Structure:
3.1 Introduction
3.2 Types of Number Systems
Decimal number system
Binary number system
Octal number system
Hexadecimal number system
3.3 Conversion of One Number System to Other Number System
3.4 One’s Complements
3.5 Two’s Complements
3.6 Computer Codes
BCD
ASCII
3.7 Rules and Laws of Boolean algebra
Rules in Boolean algebra
Laws of Boolean algebra
3.8 Basic Gates
AND Gate
OR Gate
NOT Gate
3.9 Summary
3.10 Terminal Questions
3.11 Answers

3.1 Introduction
A set of values used to represent different quantities is known as number
system. For example, a number system can be used to represent the
number of students in a class or number of viewers watching a certain TV
program and so on. The digital computer represents all kinds of information
in binary numbers. This information can be in the form of text, audio, video
and many more. Number systems are used to describe quantity or to
represent certain information.
In computer operation with binary values, Boolean logic can be used to
describe zeros and ones. A Boolean algebra is an algebra of logic. The

Sikkim Manipal University B2071 Page No.: 46


Fundamentals of Information Technology Unit 3

mathematician George-Boole (1815-1864) invented a systematic way of


manipulating logic symbols, which is referred to as Boolean algebra.
In this unit, we will study different numbering systems like decimal, binary,
octal and hexadecimal, converting techniques in numbering systems,
operations such as binary addition, subtraction, one’s and two’s
complement, computer codes, rules and laws of boolean algebra and basic
gates.
Objectives:
After studying this unit, you should be able to:
 list and explain different types of number systems
 discuss conversion in number systems
 discuss one’s and two’s complements
 list and explain BCD and ASCII
 discuss rules and laws of Boolean algebra
 list and explain basic gates

3.2 Types of Number Systems


The various number systems are :
1. Decimal number system
2. Binary number system
3. Octal Number system
4. Hexadecimal Number system

3.2.1 Decimal Number System


In this number system, ten different symbols or digits are used to represent
the numbers and hence it is called Decimal number system. The ten
symbols are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The total number of digits used in a
number system is called its base or radix. The base of the decimal number
system is 10 because there are ten different digits or symbols. The base is
written after the number as subscript such as 12110.
Example 1:
The value 754 is formed by the sum of each digit, multiplied by the base (in
this case the base is 10) in power of digit position (counting from zero):

7×102+5×101+4×100 = 700+50+4 = 754

Sikkim Manipal University B2071 Page No.: 47


Fundamentals of Information Technology Unit 3

Example: 2
Position of each digit is very important.
From example1, if you place "7" to the end: 547 it will be another value:
5×102+4×101+7×100= 500+40+7=547

Important note:
Any number in power of zero is 1;
100=1
X0=1

Zero in power of zero is 1:


00=1

3.2.2 Binary Number System


This number system uses two digits 0 and 1. Each digit 0 or 1 is called
binary digit or bit. Binary number system has a base 2, because it has only
two digits 0 and 1.
The binary system uses powers of 2. As explained previously, in decimal
number system, the number 127 actually means 1 ×102 + 2 × 101 + 7 × 100.
In the binary system, the same number (127) is represented as 1111111,
and can be written as 1 × 26 + 1× 25+ l × 24+1×23+ l × 22 + l × 21 + l × 20.
Example 3: Consider the binary number 1101.101. It can be represented
as:
1 × 23+ 1 × 22 + 0 × 21 + 1 × 20+ 1 × 2-1+ 0 × 2-2+ 1 × 2-3
Binary Addition
Binary addition is also carried out in the similar manner as decimal addition.
Rules of Binary addition are:
0+0=0
0+1=1
1+0=1
1 + 1 = 0 and a carry of 1
Since 1 is the largest digit in the binary system, any sum greater than 1
requires that a digit be carried over.

Sikkim Manipal University B2071 Page No.: 48


Fundamentals of Information Technology Unit 3

For example
1 carry bit
010
+ 010
100
The addition of the two 1’s in the second position to the left, with a carry-
over. Since 1 + 1 = 0 plus a carry-over of 1, the sum of 010 and 010 is 100.
Here are some examples of binary addition.
DECIMAL BINARY DECIMAL BINARY
6 110 15 1111
+ 7 + 111 + 20 +10100
13 1101 35 100011
Binary Subtraction
It is necessary to establish a procedure for subtracting a larger digit from a
smaller digit. The only case in which this occurs with binary numbers is
when 1 is subtracted from 0. The remainder is 1, but it is necessary to
borrow 1 from the next column to the left.
The rules of binary subtraction are:
0–0=0
1–0=1
1–1=0
0 – 1 = 1 with a borrow of 1
Following examples will make the procedure for binary subtraction clear:
DECIMAL BINARY DECIMAL BINARY
9 1001 16 10000
–5 – 101 –3 – 11
4 100 13 1101
3.2.3 Octal Number System
The octal number system has a base or radix 8. This means eight different
symbols are used to represent numbers. These symbols are 0, 1, 2, 3, 4, 5,
6 and 7.
Example 4: Consider the octal number 72601.12. It can be represented as
7×84 + 2 × 83 + 6×82 + 0×81 + 1 ×80 + 1 ×8-1 + 2× 8-2

Sikkim Manipal University B2071 Page No.: 49


Fundamentals of Information Technology Unit 3

Example 5: Consider the octal number 12673. It can be represented as


1×84 + 2 × 83 + 6×82 + 7×81 + 3 ×80
3.2.4 Hexadecimal Number System
The hexadecimal number system has a base or radix 16. So it uses 16
symbols: 0,1,2,3,4,5,6,7,8,9,A,B,C,D and E. where A is 10, B is 11, C is 12,
D is 13, E is 14 and F is 15.
Example 6: Consider the hexadecimal number 428CA. It can be
represented as
4x164 + 2x163 + 8x162 + Cx161 + Ax160
Self-Assessment Questions
1. Decimal means base __________.
2. _________and __________ bits are used in binary number system.
3. In binary addition 1 + 1 = 1 and a carry 0. (True/False)
4. Hexadecimal number system has a base ______.

3.3 Conversion of One Number System to Other Number System


There are many methods which can be used to convert numbers from one
base to another base. We will study the following:
Decimal Number to Binary Conversion – Fractional Part
When converting a fractional decimal value to binary we repeatedly multiply
the decimal fraction by 2. If the result is greater than or equal to 1, then add
1 to the answer. If the result is less than 1, then add 0 to the answer.
Example 7: Convert 0.375(10) =? (2)

Integer Fraction Integral Part


0.375 * 2 = 0 .750 0 Top
0.750 * 2 = 1 .500 1
0.500 * 2 = 1 .000 1 Bottom

Thus 0.375(10) = 0.011(2)

Example 8: Convert 25.3125(10) =? (2)


Convert decimal integer part and fraction part separately into binary and
then combine both the parts together as shown below.
25.3125(10) =? (2)

Sikkim Manipal University B2071 Page No.: 50


Fundamentals of Information Technology Unit 3

Integer part 25(10) Fraction Part 0.3125(10)


2 25 remainder Integer Fraction Integer part

2 12 1 0.125 * 2 = 0 0.6250 0

2 6 0 0.6250 * 2 = 1 0.2500 1

2 3 0 0.2500 * 2 = 0 0.5000 0

2 1 1 0.5000 * 2 = 1 0.0000 1

2 0 1
Thus, 25(10)= 11001 Thus 0.3215 (10) = 0101

Combining both part thus result is 25.3125(10) = 11001.0101(2)

Decimal Number to Binary Conversion – Integer Part


In this conversion, as binary number system uses base – 2, the given
decimal number is repeatedly divided by 2 until there is a 0 quotient. While
division is carried out the remainders generated at each division, that is 0 or
1, are written down separately. The first remainder is noted down as LSB in
the binary number and the last remainder as MSB as indicated by an arrow
mark.
Example 9: Write the binary equivalent of 29 (10) and 45 (10).
Remainder
2 29
2 14  1 LSB
2 7  0
2 3  1 29(10) = 1 1 1 0 1 (2)
2 1  1 MSB LSB
0  1 MSB

Sikkim Manipal University B2071 Page No.: 51


Fundamentals of Information Technology Unit 3

Remainder
2 45
2 22  1 LSB
2 11  0
2 5  1 45(10) = 1 0 1 1 0 1 (2)
2 2  1 MSB LSB
2 1  0
0  1 MSB

Decimal Number to Octal Conversion – Fractional Part


Conversion from decimal fraction to octal fraction, is done by successively
multiplying by its base (8). The integer part is noted down after each
multiplication and the remainder fraction is used is used for multiplication at
the next stage
Example 10: 0.75 (10) =? (8)
Integer Fraction
0.75 * 8 = 6 0.00
Thus : 0.75 (10) = 0.6 (8)

Example 11: 0.21875 (10) =? (8)


0.21875
x 8 Integer Fraction
1.7500 1 0.75000
0.7500
x 8
6.00000 6 0.0000
Thus 0.21875(10) = 0.16(8)

Decimal Number to Octal Conversion – Integer Part


In this conversion, Octal number system has base – 8. The given decimal
number is repeatedly divided by 8 until there is a 0 quotient. While division
is carried out, the remainders generated at each division, are written down
Sikkim Manipal University B2071 Page No.: 52
Fundamentals of Information Technology Unit 3

separately. The first remainder is noted down as Least Significant Digit


(LSD) in the octal number and the last remainder as Most Significant Digit
(MSD).
Example 12: Write the octal equivalent of 792 (10) and 1545 (10).

Remainder
8 792
8 99  0 LSB
8 12  3
8 1  4 792 (10) = 1430 (8)
0  1 MSB

Remainder
8 1545
8 193  1 LSB
8 24  1
8 3  0 1545(10) = 3011 (8)
0  3 MSB

Decimal Number to Hexadecimal Conversion – Fractional Part


For the conversion of decimal fraction to its hexadecimal fraction, the
method of repeated multiplication by base16 is used. The integer part is
noted down after each multiplication and the remainder fraction is used is
used for multiplication at the next stage. The result of integer is taken from
top to down.

Sikkim Manipal University B2071 Page No.: 53


Fundamentals of Information Technology Unit 3

Example 13: Convert the decimal fraction 0.62 to its equivalent


hexadecimal fraction.

Fraction Fraction × 16 Remainder Integer


0.62 9.92 0.92 9
0.92 14.72 0.72 14 = E
0.72 11.52 0.52 11 = B
0.52 8.32 0.32 8
0.32 5.12 0.12 5
0.12 1.92 0.92 1

The process will further continue. The result has been taken up to 6 places
of hexadecimal point.
Therefore, (0.62)10 = (0.9EB851)16
Decimal Number to Hexadecimal Conversion – Integer Part
In this conversion, hexadecimal number system has base – 16. So the given
decimal number is repeatedly divided by 16 until the quotient is 0. While
division is carried out, the remainders generated at each division, are written
down separately. The first remainder is noted down as Least Significant
Digit (LSD) in the hexadecimal number and the last remainder as Most
Significant Digit (MSD).
Remainder
16 215
16 13  7 LSB
16 0  13 =D MSB 21510 = D716
0

Binary Number to Decimal Conversion – Fractional Part


In this conversion negative exponents are used after the binary point (right
side). The exponential expressions of each fractional placeholder are 2-1, 2-2
in this way the exponent notation proceeds.

Sikkim Manipal University B2071 Page No.: 54


Fundamentals of Information Technology Unit 3

The steps involved in the conversion process are as follows:


1. Write the weight of each bit of the binary number
2. Multiply the weighted value with the respective bit of the binary number
3. Add all the weighted values to get the decimal fraction.

Example 14: Convert decimal equivalent of 101.11(2) and 0.111(2)

Binary number 1 0 1 1 1
Weight of each bit 22 21 20 2-1 2-2
Weighted value 4×1 2×0 1×1 ½ ×1 ¼ ×1
Solved 4 0 1 0.5 0.25
multiplication

Sum of weight of all bits = 4 + 0 + 1 + 0.5 + 0.25


= 5.75(10)

Example 15: Convert decimal equivalent of 0.111(2)

Binary number 0 1 1 1
Weight of each bit 20 2-1 2-2 2-3
Weighted value 1×0 0.5×1 1/4 ×1 1/8 ×1
Solved 0 0.5 0.25 0.125
multiplication

Sum of weight of all bits = 0 + 0.5 + 0.25 + 0.125


= 0.875(10)
Thus, the decimal equivalent of 0.111(2) is 0.875(10)

Binary Number to Decimal Conversion – Integer Part


Step 1 – Determine the column (positional) value of each digit.
Step 2 – Multiply the column values (in Step 1) by the digits in the
corresponding columns.
Step 3 – Sum the products calculated in Step 2. The total is the equivalent
value in decimal.

Sikkim Manipal University B2071 Page No.: 55


Fundamentals of Information Technology Unit 3

Example 16: Convert 11012 to decimal number.


Calculating Decimal Equivalent:
Step Binary number Decimal number
Step 1 1101(2) 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20

Step 2 1101(2) 8+4+0+1


Step 3 1101(2) 13(10)

Binary Number: 11012 = Decimal Number: 1310

Octal Number to Decimal Conversion – Fractional Part


In this conversion negative exponents are used after the binary point (right
side). The exponential expressions of each fractional placeholder are 8-1, 8-2
(the exponent notation proceeds in this manner).
The steps involved in the conversion process are as follows:
1. Write the weight of each bit of the octal number
2. Multiply the weighted value with the respective bit of the octal number
3. Add all the weighted values to get the decimal fraction.

Example 17: Write the decimal equivalent of 234.32 (8))

Octal number 2 3 4 3 2
Weight of each 82 81 80 8-1 8-2
bit
Weighted value 64 × 2 8× 3 1×4 1/8 × 3 1/64 × 2
Solved 128 24 4 0.375 0.03125
multiplication

Sum of weight of all bits = 128 + 24 + 4 + 0.375 + 0.03125


= 156.4062 (10)
Thus, the decimal equivalent of 234.32 (8) is 156.4062 (10)

Sikkim Manipal University B2071 Page No.: 56


Fundamentals of Information Technology Unit 3

Example 18: Write the decimal equivalent of 1.427 (8)

Octal number 1 4 2 7
Weight of each bit 80 8-1 8-2 8-3

Weighted value 1×1 1/8 × 4 1/64 × 2 1/512 × 7

Solved multiplication 1 .5 .0312 0.0136

Sum of weight of all bits = 1+ .5+.0312+.0136


= 1.5448 (10)
Thus, the decimal equivalent of 1.427 (8) is 1.5448 (10)
Octal Number to Decimal Conversion - Integer Part
Step 1 – Determine the column value of each digit.
Step 2 – Multiply the column values (in Step 1) by the digit 8X (where x is
the digit position).
Step 3 – Sum the products calculated in Step 2. The total is the equivalent
value in decimal.
Example 19: Convert 65 (8) to decimal equivalent
Calculating Decimal Equivalent:

Step Octal number Decimal number

Step 1 65 (8) 6 x 81 + 5 x 80

Step 2 65 (8) 48 + 5

Step 3 65 (8) 53(10)

Octal Number: 65 (8) = Decimal Number: 53(10)

Octal Number to Binary Conversion – Fractional Part


In this conversion there is a direct relation between the bases of Octal and
Binary number systems. that is 8 = 23. This indicates that one symbol of
octal can be used to replace one 3-bit representation in the binary system.

Sikkim Manipal University B2071 Page No.: 57


Fundamentals of Information Technology Unit 3

There are totally 8 combinations with 3-bit binary representation from 000 to
111, which can be mapped octal symbols 0 to 7.
To convert a given octal number to binary, simply replace the octal digit by
its equivalent 3-bit binary. Table 3.1 shows an octal number and an
equivalent 3-bit Binary representation
Table 3.1: Octal number and its equivalent 3-bit Binary representation

Octal Digit Binary Bit


0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111

Example 20: 4762.513 (8) = 4 7 6 2 . 5 1 3


= 100 111 110 010 . 101 001 011 (2)
Therefore 4762.513 (8) = 100111110010.101001011 (2)

Binary Number to Octal Conversion – Fractional Part


Representing a given binary number in octal representation is also a straight
forward conversion process. The given binary number is clubbed into a
group of three bits towards left from the octal point and grouped towards the
right from the octal point. Additional 0’s, if required, can be added to the left
of leftmost bit of integer part and to the right of rightmost bit in the fractional
part, while grouping.
Example 21: 1011001.1011 (2) = 001 011 001 . 101 100 (2)
= 1 3 1 . 5 4 (8)

Therefore 1011001.1011(2) = 131.54(8)


Note: Additional 0’s were used while grouping 3-bits.

Sikkim Manipal University B2071 Page No.: 58


Fundamentals of Information Technology Unit 3

Example 22: 101111.001 (2) = 101 111 . 001 (2)

= 5 7 . 1 (8)

Therefore 101111.001 (2) = 57.1 (8)

Hexadecimal Number to Binary Conversion - Fractional Part


Converting a Hexadecimal number to a Binary number is a precise process
since a single digit in a hexadecimal number corresponds directly to a four -
bit binary number. There are totally 16 combinations with 4-bit binary
representation from 0000 to 1111, which can be mapped 0 to 9 and A to F.
Table 3.2 shows a Hexadecimal number and its equivalent 4-bit Binary
representation.
To convert the hexadecimal number into its binary equivalent, the following
steps are involved:
1. Convert each hexadecimal digit to its four-bit binary equivalent
2. Combine the four bit blocks by removing the spaces to get the binary
number.
Table 3.2: Hexadecimal number and its equivalent 4-bit Binary representation

Octal Digit Binary Bit


0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111

Sikkim Manipal University B2071 Page No.: 59


Fundamentals of Information Technology Unit 3

Example 23: 1A62.B53 (16) = 1 A 6 2 . B 5 3(16)


= 0001 1010 0110 0010 . 1011 0101
0011(2)
Therefore 1A62.B53 (16) = 0001101001100010.101101010011 (2)
Example 24: 354.A1 (16) = 3 5 4 . A 1(16)
0011 0101 0100 . 1010 0001(2)
Therefore 354.A1 (16) = 001101010100.10100001 (2)

Binary Number to Hexadecimal Conversion – Fractional Part


Representing a given binary number in a hexadecimal representation is a
straight forward conversion process. The Binary number given is clubbed
into a group of 4-bits starting from the hexadecimal point towards left and
towards right. Additional 0’s, if required, can be added to the left of leftmost
bit of integer part and to the right of rightmost bit in the fractional part, while
grouping. Equivalent hexadecimal symbol is placed for a 4-bit binary group
to have the conversion.
Example 25: 1011001.1011 (2) = 0101 1001 . 1011 (2)
= 5 9 . B (16)

Therefore 1011001.1011 (2) = 59.B (16)


Note: Additional 0’s are used while grouping 4-bits.
Example 26: 101111.001 (2) = 0010 1111 . 0010 (2)

= 2 F . 2 (16)

Therefore 101111.001 (2) = 2F.2 (16)


Hexadecimal Number to Decimal Conversion – Integer Part
Step 1 – Determine the column value of each digit.
Step 2 – Multiply the column values (in Step 1) by the digit 16X (where x is
the digit position).
Step 3 – Sum of the products calculated in Step 2. The total is the
equivalent value in decimal.

Sikkim Manipal University B2071 Page No.: 60


Fundamentals of Information Technology Unit 3

Example 27: Convert 112816 to decimal number


Calculating Decimal Equivalent:

Step Hexadecimal number Decimal number


Step 1 112816 1x163+1x162+2x161+8x160
Step 2 112816 4096+256+32+8
Step 3 112816 4392(10)

Hexadecimal Number: 112816 = Decimal Number: 4392(10)

Example 28: Write the decimal equivalent of 58916


58916 = 5 x 162 + 8 x 161 + 9 x 160
=1280+128+9
= 1417(10)

Example 29: Write the decimal equivalent of A93(16)


A93(16) = A × 162 + 9 × 161 + 3 × 160
= 10 × 256 + 9 × 16 + 3 × 1
= 2560+ 144 + 3
= 2707(10)

Example 30: Write the decimal equivalent of CD2(16)


CD2(16) = C × 162 + D × 161 + 2 × 160
= 12 × 256 + 13 × 16 + 2 × 1
= 3072+ 208 + 2
= 3282(10)

Hexadecimal Number to Octal Conversion – Integer Part


In this conversion, each hexadecimal digit is converted to four- bit binary
form and then all are grouped to binary bits. After grouping all the four-bit
binary blocks, it is converted into three-bit form. Finally these three-bit
binary forms are converted into octal symbols.

Sikkim Manipal University B2071 Page No.: 61


Fundamentals of Information Technology Unit 3

Note: In the case of fractions Additional 0’s, if required, can be added to the
left of leftmost bit of integer part and to the right of rightmost bit in the
fractional part, while grouping.
Example 31: Find the octal equivalent of A45 (16)

Hexadecimal A 4 5
Number
Binary coded value 1010 0100 0101

Combining all four-bit binary blocks, we have 101001000101


Dividing the group of binary numbers into three-bit binary blocks and
convert these blocks into their respective octal symbols, we have
101 001 000 101
5 1 0 5
Thus octal equivalent of A45 (16) is 5105(8)
Self-Assessment Questions
5. The octal equivalent of (100)10 is ________.
6. The binary equivalent of (265)10 is _______.
7. The hexadecimal equivalent of (1011 1010 0011.0010)2 is _______.
8. The decimal equivalent of (B21)16 is___________ .
9. The binary equivalent of (BAC9)16 is_______________ .
10. The hexadecimal equivalent (2526)10 is____________.
11. The octal equivalent of (625)10 is__________.

3.4 One’s Complement


The one’s complement of a given binary number is found by changing all 0’s
to 1’s and all 1’s to 0’s.The one’s complement notation represents a
negative number by inverting the bits. Example of one’s complement is
given below:

Binary number: 0 1 0 1 0

1’s complement: 1 0 1 0 1

Sikkim Manipal University B2071 Page No.: 62


Fundamentals of Information Technology Unit 3

Negative Numbers Representation using One’s Complement.


For writing negative numbers a standard convention is adopted and it
consists of placing a sign symbol before a number that is negative. For
example, negative 27 is written as -27. If – 27 is to be added to + 45, we
write
+ 45 + (–27) = 18
But if a negative number is subtracted from a positive number, for example
the above expression can be written as +45 – (– 27) = + 45 + 27 = 72 (- and
– becomes +).
The method used to represent negative binary numbers is different from
positive numbers. The convention used is represented as, when sign bit is 0,
the number represented is positive, and when sign bit is 1, the number is
negative. For example number that is -6 is represented by 1110. The MSB
is the sign bit and remaining bits represent magnitude 6. In 1’s complement
representation, -6 is represented as 1001.This is obtained by replacing
every 1 by 0 and every 0 by 1 in the binary representation of the number
+6(0110). Table 3.3 shows representation of numbers using 1’s
complement method.
Table 3.3: Numbers using 1’s complement representation

Bit Pattern Decimal Number


0000 0
1111 -0
0001 1
1110 -1
0010 2
1101 -2
0011 3
1100 -3
0100 4
1011 -4
0101 5
1010 -5
0110 6
1001 -6
0111 7
1000 -7
Sikkim Manipal University B2071 Page No.: 63
Fundamentals of Information Technology Unit 3

Binary Subtraction Using One’s Complement:


An operation in one’s complement subtraction where the carry bit resulting
from a sum of two one’s complement numbers is added to that sum is called
an end-around-carry. The example is shown below for end-around-carry.
Minued - subtrahend = difference. For example, 712 – 585 = 127.
585 is the subtrahend, 712 is the minuend, 127 is the result
Example 32:
Perform subtraction on the given binary numbers using the one’s
complement a) 10011 – 10001
b) 1001 – 101000
Solutions:
a) The 1’s complement of the subtrahend 10001 = 01110

111 carry bits


1 0 0 1 1 : Minuend
+ 0 1 1 1 0 : 1’s complement of subtrahend.
100001
↳ +1 Add End-around carry
0 0 0 1 0 : Final result.

Since the summation produces an end carry, the result is positive.

Therefore, 10011 – 10001 = 00010.


b) 1001 – 101000
Here, the minuend (1001) has 4 digits and the subtrahend (101000) has 6
digits. At first we have to equate the number of digits of the minuend and the
subtrahend. Therefore, we add two zeros to the left of the most significant
bit of the minuend and make it (001001).
The 1’s complement of the subtrahend 101000 = 010111
11111 carry bits
001001
+010111
100000

Sikkim Manipal University B2071 Page No.: 64


Fundamentals of Information Technology Unit 3

Since there is no carry in the sum, the result is a negative number and is in
one’s complement form. So to get answer in true form, take the one’s
complement of the sum and place a negative sign in front.
The one’s complement of the result (100000) is 011111. Now attach
negative sign.
Therefore, 1001 – 101000 = – 011111
Self-Assessment Questions
12. One’s complement of 0001 is ________.
13. One’s complement of 7 for 3-bit number is _________.
14. One’s complement of -4 for 4-bit number is __________.
15. Subtract 1010 from 1111 using one’s complement __________.

3.5 Two’s Complement


The two’s complement notation builds on the one’s complement notation.
The procedure goes as follows:
1. Compute the 1’s complement
2. Add 1 to the result (1’s complement) to get two’s complement
For example, the two’s complement of 10110 is formed by the following
steps:
Step 1: Obtain 1’s complement.
10110 : Binary number
01001 : 1’s complement
Step 2: Add 1 to the result 01001.
01001
+1
01010
So the two’s complement of 10110 is 01010.
Binary Subtraction using Two’s Complement:
Subtraction using two’s complement system involves forming the two’s
complement of the subtrahend and then adding this complement to the
minuend. This is illustrated in the examples 35 and 36.

Sikkim Manipal University B2071 Page No.: 65


Fundamentals of Information Technology Unit 3

Example 33:
11001 11001
– 10100 = + 01100 (2’s complement of 10100)
00101 1 00101
Carry is dropped
Example 34: Perform subtraction on the given binary numbers using the 2’s
complement 1001 – 101000
The 2’s complement of the subtrahend 101000 = 011000

0 0 1 0 0 1: Minuend
+ 0 1 1 0 0 0: 2’s complement of subtrahend.
100001

Since the summation produces no end carry, the result is a negative


number and is in two’s complement form. So to get final answer in true form,
take the two’s complement of the sum and place a negative sign in front.
The two’s complement of the result (100001) is 011111. Now attach
negative sign to this result as: – 011111
Therefore, 1001 – 101000 = – 011111
Self-Assessment Questions
16. Two’s complement of 10101 is ___________.
17. Subtract 10102 from 11112 using two’s complement __________.

3.6 Computer Codes


A code is a group of symbols that consist of numbers, letters or words in a
specific pattern. Computer codes are used for internal representation of
data in computers. As computers use binary numbers for internal data
representation, computer codes use binary coding schemes. In binary
coding, every symbol that appears in the data is represented by a group of
bits. Commonly used computer codes are:
 BCD Code
 ASCII Code

Sikkim Manipal University B2071 Page No.: 66


Fundamentals of Information Technology Unit 3

3.6.1 BCD Code


BCD stands for Binary Coded Decimal. Another name for BCD code is 8421
code. It is a four bit code that represents one of the ten decimal digits from
0-9.
In BCD each decimal digit is represented by a four-bit code as illustrated
below:
Decimal: 0 1 2 3 4 5 6 7 8 9
BCD: 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Example 35: Write the BCD code for the decimal number 127
Solution:
Decimal : 0001 0010 0111
BCD :1 2 7
Therefore, 127 = (0001 0010 0111) in BCD
3.6.2 ASCII Code
ASCII (American Standard Code for Information Interchange) is a character
encoding scheme. Microcomputer manufactures have adapted a standard
code for representation of characters and this standard code is called as
ASCII code. Basically ACSII is a 7-bit code that represents 27=128
characters, but later it was modified to an 8-bit code. This modified 8-bit
code is an extended version of ASCII, and is called as EBCDIC (Extended
Binary Coded Decimal Interchange) and this code allows 256 different
character combinations.
Example 36: Write binary code for the word BOY in ASCII-7.
Solution: B = 1000010 in ASCII-7 binary notation
O = 1001111 in ASCII-7 binary notation
Y = 1011001 in ASCII-7 binary notation
Hence, binary coding for the word BOY in ASCII – 7
1000010 1001111 1011001
B O Y
Self-Assessment Questions
18. In BCD, each decimal digit is usually represented by _______ bits.
19. ASCII stands for ___________________.
20. In EBCDIC, 8-bit code allows ______ different character combinations.

Sikkim Manipal University B2071 Page No.: 67


Fundamentals of Information Technology Unit 3

3.7 Rules and Laws of Boolean Algebra


Boolean algebra is the subarea of algebra in which the values of the
variables are true and false, usually denoted by 1 and 0. The main
operations of Boolean algebra are the conjunction and, denoted by  (Dot
operator), the disjunction or, denoted by + (plus operator), and the negation
not, denoted by ¬.
3.7.1 Rules in Boolean algebra
The symbol that represents an arbitrary element of a Boolean algebra is
known as variable. A variable and function can have a value of either 0 or 1.
For example, in an expression Z=M+NO, variables M,N and O can have
either a value 0 or 1 and function Z can also have either a value 0 or 1.
In Boolean algebra, the logical OR operator is TRUE if one or both of the
inputs are TRUE. Table 3.4 shows a truth table for logical OR for the
statement given below:
“I will take an umbrella with me if it is raining or if the weather forecast is
bad”
Table 3.4: Truth Table for Logical OR

Raining Bad Forecast Umbrella


False False False
False True True
True False True
True True True

Logical OR operator is represented by writing a ‘+’ sign between the two


variables that is X+Y. In the similar way we can represent for three variables
X+Y+Z. A value either 0 or 1 for the logical OR operator in the Boolean
algebra gives the following results.
1+1=1 1+0=1 0+1=1 0+0=0

Sikkim Manipal University B2071 Page No.: 68


Fundamentals of Information Technology Unit 3

Basic Rules of Boolean Algebra


1. A + 0 = A
2. A + 1 = 1
3. A. 0 = 0
4. A. 1 = A
5. A + A = A
6. A + A = 1
7. A  A = A
8. A  A = 0
9. A  A
10. A + AB = A
11. A + A B = A + B
12. (A+B)(A+C) = A + BC

Demorgan’s Theorem
DeMorgan, a mathematician, contributed two theorems, which are
extremely useful while simplifying logical expression using Boolean algebra.
Theorem 1: The complement of a product is equal to the sum of the
complements

Sikkim Manipal University B2071 Page No.: 69


Fundamentals of Information Technology Unit 3

Truth Table:

a b c a bc a  b  c

0 0 0 1 1
0 0 1 1 1
0 1 0 1 1
0 1 1 1 1
1 0 0 1 1
1 0 1 1 1
1 1 0 1 1
1 1 1 0 0

Theorem 2: The complement of a sum is equal to the product of the


complements

Truth Table:

a b c abc abc

0 0 0 1 1
0 0 1 0 0
0 1 0 0 0
0 1 1 0 0
1 0 0 0 0
1 0 1 0 0
1 1 0 0 0
1 1 1 0 0

Sikkim Manipal University B2071 Page No.: 70


Fundamentals of Information Technology Unit 3

3.7.2 Laws of Boolean algebra


In Boolean algebra there are three laws
 Commutative law
 Associative law
 Distributive law

Commutative Law
Commutative law of addition: A + B = B + A
The commutative law for addition states that, it makes no difference in the
output in whatever order the variables are ORed. In this law the truth tables
are identical. Table 3.5 shows a truth table for commutative law for “OR”
operation.

Table 3.5: Truth table for commutative law for “OR” operation

The commutative law for “OR” can be extended to any number of variables.
For example,
As, A + B = B + A, we can say that for three variable, A + B + C = B + A + C.

Commutative law of multiplication: AB = BA


The commutative law for product, states that it makes no difference in the
output in whatever order the variables are ANDed. In commutative law the
truth tables are identical, Table 3.6 shows a truth table for commutative law
for “AND” operation.

Sikkim Manipal University B2071 Page No.: 71


Fundamentals of Information Technology Unit 3

Table 3.6: Truth table for commutative law for “AND” operation

The commutative law for “AND” can be extended to any number of variables.
For example, for three variables, ABC = BAC.
Associative Law
Associative law of addition: A + (B + C) = (A + B) + C.
The associative law for addition, states that it makes no difference in
whatever order the variables are grouped, the result is same for several
variables. Table 3.7 shows a truth table for associative law for “OR”
operation.
Table 3.7: Truth table for associative law for “OR “operation

Associative law of multiplication: (AB) C = A (BC).


This law states that it makes no difference in whatever order the variables
are grouped, the result is same for several variables. Table 3.8 shows a
truth table for associative law for “AND” operation.

Sikkim Manipal University B2071 Page No.: 72


Fundamentals of Information Technology Unit 3

Table 3.8: Truth table for associative law for “AND” operation

Distributive law
Distributive law: A (B+C) = AB + AC
The Distributive law states that ORing several variables and ANDing the
result with a single variable is equivalent to ANDing several variables and
then ORing the products. Table 3.9 shows a truth table for distributive law.
.
Table 3.9: Truth table for distributive law

Self-Assessment Questions
21. If X=0, X+ X =_______.
22. X =_______.
23. If x, y, z contains values 0, 1, 1 then (x+z) y is _______.
24. A (B + C) = AB +AC is __________ law.

Sikkim Manipal University B2071 Page No.: 73


Fundamentals of Information Technology Unit 3

3.8 Basic Gates


A gate is an electronic circuit which operates on one or more input signals to
produce an output signal. It can also be defined as a digital circuit with one
or more inputs but only one output. A gate (or a logic gate) produces logical
operation on binary numbers. There are three types of basic gates: AND,
OR and NOT. These basic gates also called as logic gates and perform
logical functions. These gates operate only on binary inputs. With the help
of the “truth table” the operations of a logic gates can be easily understood.
In this section we will study three basic gates AND, OR and NOT

3.8.1 AND Gate


The two logical values are true and false. The true represents the binary
value 1 and false represents binary value 0. In AND gate, output is true only
when all the inputs are true. Operator called Dot “·” is used for AND function
representation. So if a and b are the two inputs of a two-input AND gate,
then its output x is given by x = ab. Figure 3.1 shows a symbol of AND gate
and Table 3.10 shows a truth table of AND gate.
Table 3.10: Truth Table of AND gate

Input Input Output


a a b X = a. b
x  a.b 0 0 0
b
0 1 0
1 0 0
Figure 3.1: Symbol of AND Gate
1 1 1
Note: Similarly AND operation can be
defined for three or more inputs. For example a three input AND operation
can be given by x = a. b. c or by x = abc. A three input AND gate uses a, b,
c as the three input terminals and has one output terminal x.
3.8.2 OR Gate
In OR gate, output is true when any one of the inputs or all the inputs are
true. Let the inputs variables for a two input OR gate are denoted by ‘a’ and
‘b’ and the output variable by x, then the OR function ‘x’ is represented by
x = a + b where + operator is used for OR function representation. Figure
3.2 shows a symbol of OR gate and Table 3.11 shows its truth table.

Sikkim Manipal University B2071 Page No.: 74


Fundamentals of Information Technology Unit 3

Table3.11: Truth Table of OR gate

Input Input Output


a a b x=a+b
x ab
b 0 0 0
0 1 1
Figure 3.2: Symbol of OR Gate
1 0 1
1 1 1

Note: Similarly OR operation can be defined for three or more inputs. For
example a three input OR operation can be given by x = a + b + c where a,
b, c are three input terminals and x is the output terminal.
3.8.3 NOT Gate
A NOT gate changes true to false and vice versa. A logical inversion or
negation is represented by NOT function.
Inversion logic or NOT function is represented by ‘bar’ over the variable. If a
is the input line or terminal and X is the output line, then X  a . Figure 3.3
shows a symbol of NOT gate and Table 3.12 shows a truth table of NOT
gate.
Table 3.12: Truth Table of NOT gate

Input Output
a X
a X a 0 1
1 0
Figure 3.3: Symbol of NOT Gate

Self-Assessment Questions
25. A ______________ is an electronic circuit which operates on one or
more input signal to produce an output signal.
26. Boolean product of 1 and 0 in AND has ____ value.
27. Boolean sum of 1 and 0 in OR has _____ value.
28. Mention different types of basic gates.
29. A logical inversion or negation is represented by _________ gate.

Sikkim Manipal University B2071 Page No.: 75


Fundamentals of Information Technology Unit 3

3.9 Summary
 A decimal number system has a base 10 and consists of ten digits
(0 to 9).
 A binary number system has a base 2 and consists of two digits (called
bits) 1 and 0.
 The octal number system has a base of 8 and consists of eight digits
(0 to 7)
 The hexadecimal number system has a base of sixteen and consists of
16 digits ( 0 through 9 and A to F)
 The 1’s complement of a binary number is derived by changing 1s to 0s
and 0s to 1s
 The 2’s complement of a binary number is derived by adding 1 to the 1’s
complement
 Binary subtraction can be accomplished by addition using the 1’s or 2’s
complement methods
 Octal to binary conversion is accomplished by simply replacing each
octal digit with its three-bit binary equivalent.
 To represent characters in computers there are different coding
schemes like BCD Code and ASCII Code.
 Different rules are defined in the Boolean algebra for AND, OR and NOT
operator.
 Three basic laws of Boolean algebra are the commutative, associative
and distributive laws.
 A gate is an electronic circuit which operates on one or more input
signals to produce an output signal. There are three basic gates- OR,
AND, NOT etc.
 In AND gate, output is true only when both the inputs are true.
 In OR gate, output is true when any one of the inputs or all the inputs
are true.
 In NOT gate, output is negation (If the input is True then the output will
be False OR if the input is False then the output will be True).

Sikkim Manipal University B2071 Page No.: 76


Fundamentals of Information Technology Unit 3

3.10 Terminal Questions


1. Convert the following binary numbers to base 10:
a. 10101101
b. 110110
2. Convert the following octal numbers to base 10:
a. 273
b. 1021
3. Convert the following hexadecimal numbers to base 10:
a. 145
b. A2C1
4. Convert the following decimal numbers to base 2:
a. 122
b. 98
5. Convert the following decimal numbers to hexadecimal:
a. 1145
b. 2421
6. Determine the base b in each of the following cases:
a. (361)10 =(551)b
b. (859)10 =(35B)b
c. (982)10 =(1726)b
7. Write short note on BCD and ASCII code.
8. Explain rules and laws of Boolean algebra.
9. List and explain basic logic gates.

3.11 Answers
Self-Assessment Questions
1. 10
2. 0 and 1
3. False
4. 16
5. 1448
6. 1000010012
7. BA3.216
8. 284910
9. 10111010110010012
Sikkim Manipal University B2071 Page No.: 77
Fundamentals of Information Technology Unit 3

10. 9DE 16
11. 11618
12. 1110
13. 000
14. 1011
15. 01012
16. 010112
17. 01012
18. Four
19. American Standard Code for Information Interchange
20. 256
21. 1
22. X
23. 1
24. Distributive
25. Gate
26. 0
27. 1
28. AND,OR,NOT
29. NOT
Terminal Questions
1. a) 173 (Refer to section 3.3)
b) 54 (Refer to section 3.3)
2. a)187 (Refer to section 3.3)
b) 529 (Refer to section 3.3)
3. a) 325 (Refer to section 3.3)
b) 41665 (Refer to section 3.3)
4. a)1111010 (Refer to section 3.3)
b) 1100010 (Refer to section 3.3)
5. a) 479 (Refer to section 3.3)
b) 975 (Refer to section 3.3)
6. a) 8 (Refer to section 3.3)
b) 16 (Refer to section 3.3)
c) 8 (Refer to section 3.3)

Sikkim Manipal University B2071 Page No.: 78


Fundamentals of Information Technology Unit 3

7. BCD Code (Binary Coded Decimal): It is a four bit code that represents
one of the ten decimal digits from 0-9. (Refer to section 3.6)
ASCII Code: ASCII (American Standard Code for Information
Interchange) is a 7 bit character encoding scheme. (Refer to section 3.6)
8. Rules in Boolean algebra
The symbol that represents an arbitrary element of a boolean algebra is
known as variable. A variable and function can have a value either 0 or
1. (Refer to section 3.7)
Laws of Boolean algebra
In Boolean algebra there are basically three laws
o Commutative law
o Associative law
o Distributive law (Refer to section 3.7)

9. Basic Gates (NOT, AND & OR)


The basic gates are: AND, OR and NOT. These basic gates also called
as logic gates, perform logical functions. (Refer to section 3.8)

Sikkim Manipal University B2071 Page No.: 79

You might also like