CHAPTER 2
Data Representation and Boolean Algebra
Number system
• The number of symbols used in a number system is called base or radix.
Number System Base Symbols used Example
Binary 2 0, 1 (1101)2
Octal 8 0, 1, 2, 3, 4, 5, 6, 7 (236)8
Decimal 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (5876)10
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Hexadecimal 16 (A, B, C, D, E, F represents 10, 11, 12, 13, 14, 15 (12AF)16
respectively)
• MSD: The leftmost digit of a number is called Most Significant Digit (MSD).
• LSD: The right most digit of a number is called Least Significant Digit (LSD).
Number Conversions
Decimal to binary conversion
Repeated division by 2 and grouping the remainders( 0 or 1)
Example: Convert (30)10 to binary.
2 Remainders
2 0
2 1
2 1
2 1
0 1
(30)10 = (11110)2
Decimal fraction to binary
1. Multiply the decimal fraction by 2.
2. Integer part of the answer will be first digit of binary fraction.
3. Repeat step 1 and step 2 to obtain the next significant bit of binary fraction.
Example: Convert (0.625)10 to binary.
0.625 x 2 = 1.25
1 0.25 x 2 = 0.50
0 0.50 x 2 = 1.00
1 .00
(0.625)10 = (0.101)2
Decimal to Octal conversion
Repeated division by 8 and grouping the remainders.(0,1,2,3,4,5,6 or 7)
Example: Convert (120)10 to octal.
8 120 Remainders
8 15 0
8 1 7 (120)10 = (170)8
8 0 1
Decimal to Hexadecimal conversion
Repeated division by 16 and grouping the remainders( 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E or F)
Example: Convert (165)10 to hexadecimal.
16 165 Remainders
16 10 5
16 0 10 (A) (165)10 = (A5)16
Binary to decimal conversion
Multiply binary digit by place value (power of 2) and find their sum.
Example: Convert (110010)2 to decimal.
(110010)2 = 1×25 + 1×24 + 0×23 + 0×22 + 1×21 + 0×20 Weight 25 24 23 22 21 20
= 32 + 16 + 0 + 0 + 2 + 0 = (50)10 Bit 1 1 0 0 1 0
Binary fraction to decimal
Mu
lt
ip
lybinary digit by place value (negative power of 2) and find their sum.
Example: Convert (0.101)2 to decimal. Weight 2-1 2-2 2-3
(0.101)2 = 1×2-1 + 0×2-2 + 1×2-3 Bit 1 0 1
= 0.5 + 0 + 0.125 = (0.625)10
Octal to decimal conversion
Multiply octal digit by place value (power of 8) and find their sum.
Example: Convert (167)8 to decimal.
(167)8 = 1×82 + 6×81 + 7×80
Weight 82 81 80
= 64 + 48 + 7 = (119)10
Octal digit 1 6 7
Hexadecimal to decimal conversion
Multiply hexadecimal digit by place value (power of 16) and find their sum.
Example: Convert (2B5)16 to decimal.
(2B5)16 = 2×162 + 11×161 + 5×160
Weight 162 161 160
Hexadecimal digit 2 B 5
= 512 + 176 + 5
= (693)10
Octal to binary conversion
Converting each octal digit to its 3 bit binary equivalent.
Octal digit 0 1 2 3 4 5 6 7
Binary equivalent 000 001 010 011 100 101 110 111
Example: Convert (437)8 to binary.
3- bit binary equivalent of each octal digits are
4 3 7
100 011 111
(437)8 = (100011111)2
Hexadecimal to binary conversion
Converting each hexadecimal digit to its 4 bit binary equivalent.
Example: Convert (AB)16 to binary.
Octal digit 0 1 2 3 4 5 6 7 8 9 A B C D E F
Binary equivalent 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
4- bit binary equivalent of each hexadecimal digits are
A B
(AB)16 = (10101011)2
1010 1011
Binary to octal conversion
Form groups of 3 bits each from right to left and then convert each to its octal form
Example: Convert (10111000011)2 to octal.
Group the given binary number from right as shown below:
010 111 000 011
if the left most group
does not have 3 bits, (10111000011)2 = (2703)8
2 7 0 3
then add leading zeros
to form 3 bit binary.
Binary to Hexadecimal conversion
Form groups of 4 bits each from right to left and then convert each to its hexadecimal form
Example: Convert (100111100111100)2 to hexadecimal.
0100 1111 0011 1100 (100111100111100)2 = (4F3C)16
if the left most group
does not have 4 bits,
then add leading zeros 4
to form 4 bit binary. 15(F) 3 12(C)
Octal to hexadecimal conversion
Convert octal to binary and then binary to hexadecimal.
Example: Convert (537)8 to hexadecimal equivalent.
First convert (537)8 into binary.
5 3 7
= (101011111)2
101 011 111
Then convert (101011111)2 into hexadecimal.
0001 0101 1111
1 5 15(F) = (15F)16
(537)8 = (15F)16
Hexadecimal to octal conversion
Convert hexadecimal to binary and then binary to octal.
Example: Convert (A3B)16 into octal equivalent.
First convert (A3B)16 into binary.
A 3 B
= (101000111011)2
1010 0011 1011
Then convert (101000111011)2 into octal.
101 000 111 011
= (5073)8 (A3B)16 = (5073)8
5 0 7 3
Representation of integers
3 methods : (i) Sign and magnitude representation, (ii) 1’s complement representation &
(iii) 2’s complement representation
i) Sign and magnitude representation (8 bit form)
• Find binary equivalent of integer
• Make the first bit 1 for negative numbers and 0 for positive numbers.
= 10111
= 00010111
Sign and magnitude of +23 = 00010111
= 10111
= 00010111
Sign
and magnitude of -23 = 10010111
ii) 1’s complement representation
• If the number is negative, it is represented as 1’s complement of 8-bit form binary.
• 1’s complement of a binary is obtained by changing 0 to 1 and 1 to 0.
• If the number is positive, the 8-bit form binary itself is the 1’s complement.
Example: Represent +23 in 1’s complement form.
Binary of 23 in 8-bit form = (00010111)2
+23 in 1’s complement form = (00010111)2(For +ve numbers, no need to find 1’s
complement)
Example: Represent -23 in 1’s complement form.
Binary of 23 in 8-bit form = (00010111)2
-23 in 1’s complement form = (11101000)2 (by replacing 0 with 1 and 1 with 0)
iii) 2’s complement representation
• 2’s complement of a binary number is calculated by adding 1 to its 1’s complement.
• If the number is negative, it is represented as 2’s complement of 8-bit form binary.
• If the number is positive, 8-bit form binary itself is the 2’s complement.
Example: Represent +23 in 2’s complement form.
Binary of 23 in 8-bit form = (00010111)2
+23 in 2’s complement form = (00010111)2(For +ve numbers, no need to find 2’s
complement)
Example: Represent -23 in 2’s complement form.
Binary of 23 in 8-bit form = (00010111)2
-23 in 1’s complement form = (11101000)2 (by replacing 0 with 1 and 1 with 0)
-23 in 2’s complement form = 11101000 +
1
= (11101001)2
Representation of floating point numbers
• Any number in floating point notation contains two parts, mantissa and exponent.
• Eg: 25.45 can be written as 0.2545×102, where 0.2545 is the mantissa and the power 2 is the
exponent.
Representation of characters
Different methods to represent characters in computer memory are: ASCII, Unicode, ISCII,
EBCDIC
ASCII(American Standard Code for Information Interchange)
• Uses 7 bits per character, can represent only 128 characters.
• ASCII-8, which uses 8 bits, can represent 256 characters.
EBCDIC(Extended Binary Coded Decimal Interchange Code)
• 8 bit code used in IBM Machines. It can represent 256 characters.
ISCII
• It stands for Indian Standard Code for Information Interchange or Indian Script
Code for Information Interchange.
• It is an 8 bit code for representing various languages of India.
Unicode (Universal Code)
• Unicode used 16 bits or more, can represent up to 65,536 characters.
• It can represent almost all written languages of the world.
Boolean Algebra: (Algebra of logic)
• It deals with the operations on variables that represent the values 1 and 0.
• The variables which can store logical constants 1 and 0 are called logical variables or
boolean variables.
Boolean operations:
• OR (Logical Addition), AND (Logical Multiplication) and NOT (Logical Negation).
Logic gate:
• It is a physical device that can perform logical operations on one or more logical inputs and
produce a single logical output. .
Truth Table: It is a table that shows Boolean operations and their results.
The OR operator and OR gate.
Performs logical addition and the symbol used for this operation is + (plus). The
expression A + B is read as A OR B.
Truth table of OR operation
A B A+B OR
0 0 0
0 1 1
1 0 1
Gate
1 1 1
The AND operator and AND gate
Performs logical multiplication and the symbol used for this operation is ● (dot). The expression A ●
B is read as A AND B.
A B A .B AND GATE
0 0 0
0 1 0
1 0 0
1 1 1
The NOT operator and NOT gate(Inverter):
It has only one input and one output. The output is the complement (opposite state) of the input.
A A' NOT GATE
1 0
0 1
Basic postulates of Boolean Algebra
Postulate 1: Principles of 0 and 1
If A ≠ 0 then A=1 , if A ≠ 1, then A=0
Postulate 2: OR(Logical Addition)
Postulate 3: AND(Logical Multiplication)
Postulate 4: NOT(Logical Negation or Complement Rule)
0’=1 1’=0
Principle of Duality
For a Boolean statement, there exists its dual form which can be derived by
1. changing each OR (+) to AND (.)
2. changing each AND(.) to OR(+)
3. replace 0 by 1 and 1 by 0.
eg: Dual of A+A’=1 is A. A’=0
Basic Theorems of Boolean Algebra
De
Morgan’s Theorems
(i) The complement of sum of Boolean variables is equal to the product of their individual
complements . (X+Y)’ =X’.Y’
(ii) The complement of product of Boolean variables is equal to the sum of their individual
complements . (X.Y)’=X’+Y’
Circuit designs for some Boolean expressions
Expression Logical Circuit
∫ (A,B)= A’+B
∫ (X,Y)= X.Y + Y’
∫ (a,b)= (a+b).(a’+b’)
∫ (a,b)= (a’.b)+(a.b’)
Universal Gates:
NAND and NOR (It can implement any Boolean function without using any other gate type)
Gate Cicuit Logical Truth table
symbol
NAND (inverted AND
gate)
eg: For inputs, A and
B, the result Y=(A.B)’
NOR(inverted OR
gate)
eg: For inputs, A and
B, the result Y=(A+B)’
Implementation of basic gates using NAND and NOR
Gate NOT gate AND gate OR gate
NAND
NOR