Number Systems: Decimal, Binary, Octal, Hexadecimal
Number Systems: Decimal, Binary, Octal, Hexadecimal
Unit – 4
Number representation
A number can be represented with different base values. We are familiar with the
numbers in the base 10 (known as decimal numbers), with digits taking values 0,1,2,
…,8,9.
A computer uses a Binary number system which has a base 2 and digits can have only
TWO values: 0 and 1.
A decimal number with a few digits can be expressed in binary form using a large
number of digits. Thus the number 65 can be expressed in binary form as 1000001.
The binary form can be expressed more compactly by grouping 3 binary digits together to
form an octal number. An octal number with base 8 makes use of the EIGHT digits
0,1,2,3,4,5,6 and 7.
To summarize
Decimal : base 10
Binary : base 2
Octal: base 8
Hexadecimal : base 16
n-1 n-2 …… …… 3 2 1 0
2 2 2 2 2 2
Thus to convert any binary number replace each binary digit (bit) with its power and add
up.
Example: convert (1011)2 to its decimal equivalent
Represent the weight of each digit in the given number using the above table.
n-1 n-2 …… …… 3 2 1 0
2 2 2 2 2 2
1 0 1 1
Now add up all the powers after multiplying by the digit values, 0 or 1
(1011)2
= 23 x 1 + 22 x 0 + 21 x 1 + 20 x 1
=8 + 0 +2 +1
= 11
Example 2
Find the decimal equivalent of the binary number (1 1 1 1 1)2.
Solution
The equivalent decimal number is
= 1 × 24 + 1 × 23 + 1 × 22 + 1 × 21 + 1 × 20
= 16 + 8 + 4 + 2 + 1
= (31)10
Example
Convert (13)10 to an equivalent base-2 number.
Soluti
on Quotient Remainder
13 1
6
2
6 0
3
2
3 1
1
2
1 1
0
2
1 1 0 1
Thus, (13)10 = (1101)2
0 . -1 -2 -3 -4 … .... …
2 2 2 2 2
. 1 0 1 1 0 0 0
Example
Convert (0.65625)10 to an equivalent base-2 number.
1 0 1 0 1
The decimal equivalent of this binary number 0.1011 can be worked out by considering
the weight of each bit. Thus in this case it turns out to be
The digits are placed in the order in which they are generated, and not in the reverse
order. Let us say we need the accuracy up to 4 decimal places. Here is the result.
Answer = 0. 1 0 1 0…..
Answer = 1 0 0 0 1 1 0 . 1 0 1 0….
n-1 n-2 …… …… 3 2 1 0
8 8 8 8 8 8
6 3 2
= 384 + 24 + 2
= (410)10
Answer = 2 6 1
Note: the answer is read from bottom to top as (261)8, the same as with the binary case.
Conversion of decimal fraction to octal fraction is carried out in the same manner as
decimal to binary except that now the multiplication is carried out by 8.
Example: convert (177.523)10 to its binary equivalent up to 6 decimal places using octal
form.
Step 1: convert 177 to its octal form first, to get (2 6 1)8 and then convert that to the
binary form as shown above, which is ( 010 110 001)2
Step 2: convert 0.523 to its octal form which is (0.413..)8
Step 3: convert this into the binary form, digit by digit. This yields (0.100 001 011…)
Step 4: Now put it all together
( 010 110 001 . 100 001 011…)2
• Groups are formed beginning with the Least Significant Bit and progressing to the MSB.
Start from right hand side and proceed to left. If the left most group contains only a
single digit or a double digit, add zeroes to make it 3 digits.
• Thus
11 100 1112
= 011 100 1112
= 3 4 78
And
1 100 010 101 010 010 0012
= 001 100 010 101 010 010 0012
= 14252218
Now it can be converted into the decimal form.
= 18 / 16 = 1 remainder 2
= 1 / 16 = 0 remainder 1
Answer: 1 2 A 0
Note: the answer is read from bottom to top , same as with the binary case.
= 3840 + 64 + 12 + 0
= (3916)10
• Conversion of binary numbers to hex simply requires grouping bits in the binary numbers
into groups of four bits.
• Groups are formed beginning with the LSB and progressing to the MSB.
Now we can write the binary (BCD) equivalent codes of each number.
2 = 0010
9 = 1001
4 = 0100
5 = 0101
So,
(2945)Decimal = (0010100101000101)BCD
BCD numbers are useful for the places where decimal information are transferred into or out of a
digital system. For example the circuit inside the pocket calculators can process BCD numbers,
because you enter a decimal number through a keypad, and see the decimal result on the display.
Other examples of the BCD systems are electronic counters, digital clocks, Medical equipments,
Electronic voltmeters, etc.
The following table shows the BCD numbers.
From 10 to 15 it is considered as the don’t care, because if we want to enter (10) with the keyboard
or keypad, first we press 1 who’s binary value is sent and then we press 0, a binary value of zero is
sent. So that’s why in BCD we consider numbers and their codes from 0 to 9.
Excess-3 Code in Digital Electronics:
A decimal code that has been used in some old computers is the Excess-3 code. This is an
unweighted code; its code assignment is obtained from the corresponding value of BCD after the
addition of 3.
The following table shows the representation/conversion of the BCD code into Excess-3 code.
On the sending side, the message ( in this case the first four bits) is applied to a parity generator,
where the required parity bit is generated. The message including the parity bit is transferred to its
destination.
On the receiving end, all the incoming bits are applied to a “Parity Checker”, the parity bit is
inhaled by the parity checker and the message is transferred to the destination
ASCII Code:
ASCII stands for the American standard code for information interchange. ASCII has been adopted
by several American computer manufacturers as their computer’s internal code. ASCII is of two
types ASCII-7 and ASCII-8.
ASCII-7 is a 7-bit code that allows 128 (2) 7 different characters. The first three bits are used as
zone bits and the last 4-bits indicate the digit.
ASCII-8 is an extended version of ASCII-7. It is an 8-bit code that is, it uses eight bits to represent
a letter or a punctuation mark. Eight bits are called a byte. A binary code with eight digits, such as
1001 10112, can be stored in one byte of computer memory.
Possible combinations 28 = 256
From 0 to 255.
Example 2.8
Find the one’s complement of the following binary numbers.
Solution
(a) 1011000110 (b) 00100101
From the above examples, it can be observed that for an n-bit number, the maximum positive
number which can be represented in 1’s complement representation is (2 n 1 1) and the
maximum negative number is (2n 1 1).
2.1.2 Two’s Complement Representation
If 1 is added to 1’s complement of a binary number, the resulting number is known as the two’s
complement of the binary number. For example, 2’s complement of 0101 is 1011. Since 0101
represents (+5)10, therefore, 1011 represents ( 5)10 in 2’s complement representation. In this
representation also, if the MSB is 0 the number is positive, whereas if the MSB is 1 the number
is negative. For an n-bit number, the maximum positive number which can be represented in 2’s
complement form is (2n 1 1) and the maximum negative number is 2n 1. Table 2.3 gives sign-
magnitude, 1’s and 2’s complement numbers represented by 4-bit binary numbers. From the
table, it is observed that the maximum positive number is 0111 = + 7, whereas the maximum
negative number is 1000 = 8 using four bits in 2’s complement format.
Logic gates
Positive and Negative logic System
There are two types of representations used in digital systems, the positive logic and the negative
logic representations.
In positive logic representation Bit 1 represents Logic high and Bit 0 represent a Logic low as
shown in bellow figure. High is represented by +5 Volts and low is represented by -5 Volts or 0
Volts.
In Negative logic representation Bit 1 represents logic low and Bit 0 represents logic high as shown
in bellow figure. In terms of voltage level, bit 1 can be represented as +5V and bit 0 can be
represented as 0 V or -5 Volts
Truth Tables
Truth tables are used to help show the function of a logic gate.
Truth tables help understand the behaviour of logic gates.
They show how the input(s) of a logic gate relate to its output(s).
The gate input(s) are shown in the left column(s) of the table with all the different possible
input combinations. This is normally done by making the inputs count up in binary.
The gate output(s) are shown in the right hand side column.
OR gate symbol is
Circuit diagram:
Truth table:
Input (A) Input (B) Output (Y= A+B)
0 0 0
0 1 1
1 0 1
1 1 1
This circuit will give high output (1), if any input is high (1),
otherwise the output is low (0)
Circuit diagram:
Truth table:
Input (A) Input (B) Output (Y= A .B)
0 0 0
0 1 0
1 0 0
1 1 1
This circuit will give high o utput (1), if both inputs is high (1) , otherwise
the output is low(0)
IC7408 is a 14 pin TTL integrated circuit with four AND gates inside. It is therefor called as Quad
AND gate IC.
YA
Circuit diagram:
Truth table:
Input (A) Output (Y= A )
0 1
1 0
This is the simplest gate it just inverts the input, if input is high the output
will be low and conversely
One element clearly missing from the set of Boolean operations is that of Exclusive -OR,
often represented as XOR. Whereas the OR function is equivalent to Boolean addition,
the AND function to Boolean multiplication, and the NOT function (inverter) to Boolean
complementation, there is no direct Boolean equivalent for Exclusive -OR.
Logic Symbol :
A
Y = A B
Truth Table:
0 0 0
0 1 1
1 0 1
1 1 0
The output of an XOR gate is high (1) only when exactly one of its inputs is high (1) .
If both of an XOR gate's inputs are low (0) , or if both of its inputs are high (1) , then the output
of the XOR gate is low.
IC 7486 is the standard packaging of EX-OR gate. It consist of four two input EX-OR gates.
The pin configuration of IC 7486 is as shown in the figure below:
Universal Gates:
The NAND and NOR gates are called as “Universal gates” because it is possible to implement any
Boolean expression with the help of only NAND or only NOR gates.
Hence a user can build any combinational circuit with the help of only NAND gates or only NOR
gates.
Truth table:
Y A B
Output (Y A B )
0 0 1
0 1 0
1 0 0
1 1 0
This circuit will give high output (1), if both inputs is low (0) ,
otherwise the output is low (0)
The symbol is an OR gate with a small circle on the output. The small circle
represents inversion.
Logic Symbol : Y A B
or
Or
Truth table:
This circuit will give high outpu t (1), if any inputs is low (0),
otherwise the output is low(0)
The symbol is an AND gate with a small circle on the output. The
small circle represents inversion.
IC 7400 is a 14 pin TTL integrates circuit four, two input NAND gates inside.
The pin configuration of IC 7400 is also as shown in the figure.
4.3Boolean Algebra
Boolean Algebra
Boolean Algebra is used to analyze and simplify the digital (logic) circuits. It
uses only the binary numbers i.e. 0 and 1. It is also called as Binary Algebra
or logical Algebra. Boolean algebra was invented by George Boole in 1854.
Variable used can have only two values. Binary 1 for HIGH and Binary
0 for LOW.
Boolean Laws
There are six types of Boolean Laws.
1. Commutative law
Any binary operation which satisfies the following expression is referred to
as commutative operation.
Commutative law states that changing the sequence of the variables does
not have any effect on the output of a logic circuit.
2. Associative law
This law states that the order in which the logic operations are performed
is irrelevant as their effect is the same.
3. Distributive law
Distributive law states the following condition.
4. AND law
These laws use the AND operation. Therefore they are called as AND laws.
5. OR law
These laws use the OR operation. Therefore they are called as OR laws.
De Morgan's Theorems
De Morgan has suggested two theorems which are extremely useful in
Boolean Algebra. The two theorems are discussed below.
Theorem 1
The left hand side (LHS) of this theorem represents a NAND gate with
inputs A and B, whereas the right hand side (RHS) of the theorem
represents an OR gate with inverted inputs.
This OR gate is called as Bubbled OR.
Theorem 2
Duality theorem:
It says, Start with the Boolean expression. We can drive another relation by
changing each OR sign to AND sign. Changing each AND to OR sign
Then complementing any 0 or 1 in the expression.
Example
A. (B+C)=A.B+A.C
A+(B.C)=(A+B).(A+C)
SUM-OF-PRODUCTS METHOD
Fundamental product:
The four possible ways of two input AND gate that are in
complemented and uncomplemented form. These output are called
fundamental products. This idea of fundamental products applies to
three or more inputs variables. For 3 input AND gate there are eight
possible output states. Those are shown in bellow truth table.
KARNAUGH MAP
Karnaugh map is drawing that shows all the fundamental products
and the corresponding output values of the truth table.
Karnaugh map:
The variables are A and B and the components are 0 and 1. The vertical
column consists A followed by A. The horizontal column consists followed by
B. Now In the truth table the first output 1 appears for A=0 and B=1. The
Prepared by : Dr.A.N. GnanaJeevan, Lect/Computer Page 33 of 53
fundamental product for this is AB. Enter this fundamental products on the
Karnaugh map shown above figure.
This 1’s represents AB, because 1’s is in row A and in column B. Similarly
the truth table, next high output in truth table is appear in fundamental
products are AB and the next high output in AB and placed it in the
Karnaugh map.
Karnaugh map:
Karnaugh map:
In the four variable column map the vertical column has AB, AB, AB
and AB and the horizontal row has CD, CD, CD and CD. The truth table have
output1’s appearing for A,B,C,D inputs of
01,0010,0100,010,0111,1001,1010,1011and 1101 and the fundamental
products for this input condition are ABCD, ABCD, ABCD,ABCD, ABCD,
ABCD, ABCD, ABCD, ABCD, ABCD and then enter 1’s in the Karnaugh map
as shown in above figure. Final step is enter remaining spaces are 0’s.
KARNAUGH MAP REDUCTION:
1) Pairs
2) Quads
3) Octet
Pairs:
The two horizontally or vertically adjacent 1’s are in the Karnaugh
map. In the pair of horizontally or vertically adjacent 1’s you can eliminate
the variables that appears in both complemented and uncomplemented
form. The remaining variables will be only 0’s appearing in single product
CD CD CD CD
A B 0 0 0 0
A B 0 1 1 0
A B 0 1 1 0
A B 0 0 0 0
Octet:
Besides Pairs and Quads there is one more group of adjacent 1’s to
look for Octet. This is group of eight 1’s like those of below figure. An Octet
eliminates three variables and their complements.
CD CD CD CD
A B 0 0 0 0
A B 0 0 0 0
A B 1 1 1 1
A B 1 1 1 1
Redundant group:
A group of 1’s on Karnaugh map that are all the parts of other groups. You
can eliminate redundant group. In the (A) table all the 1s of the quad are
used by the pairs by overlapping. Because of , the quad is redundant and
can be eliminated to get (B) table. In that the pairs cover all the 1s.
(A) (B)
CD CD CD CD CD CD CD CD
AB 0 0 1 0 AB 0 0 1 0
In some digital system certain input condition not occur during normal
operation. Therefore the corresponding output never occurs. Since, the
output never appears which is indicating by an x in the truth table.
A B C D Y
0 0 0 0 0
0 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
1 0 0 0 0
1 0 0 1 1
1 0 1 0 X
1 0 1 1 X
1 1 0 0 X
1 1 0 1 X
1 1 1 0 X
1 1 1 1 X
For instance, the above truth table when the output is low all output is
increasing from 0000 to 1000, high for 1001 and an x for 1010 through
1111. The x is called the don’t care condition. Whenever you see an x in the
truth table, you can see let it equal either 0 or 1 which produce the simple
PRODUCT OF SUM:
The logical product of those fundamental sums that produce output 0 in
the truth table. The corresponding logic circuit is an OR-AND circuit, or the
equivalent NOR-NOR circuit.
The product of sum method is similar and vice versa of sum of product.
A B C Y
0 0 0 0 A+B+C
0 0 1 1
0 1 0 1
0 1 1 0 A+B+C
1 0 0 1
1 0 1 1
1 1 0 0 A+B+C
1 1 1 1
The product of sum method is the fundamental sum produce output 0 for
the corresponding input condition. Above truth table is want to get the
product of sum equation is to locate each output in that Truth table and
write down this fundamental sum. The first output appears for A=0,B=0 and
C=0 . Then fundamental sum of this input A+B+C. This produces an output
0 for the corresponding input condition.
Y=A+B+C=0+0+0=0
Similarly, for 2,3 output 0 occurs for A=0,B=1,C=1 and A=1,B=1,C=0.
Therefore its fundamental sum is
I Y=A+B+C=0+1+1=0
II Y=A+B=C=1+1+0=0
To get the product of sum equation we have to this AND the
fundamental sum.
Y=(A+B+C). (A+B+C). (A+B+C)
Arithmetic Circuits
Half Adder
Half adder is a combinational logic circuit with two inputs and two outputs.
The half adder circuit is designed to add two single bit binary number A
and B. It is the basic building block for addition of two single bit numbers.
This circuit has two outputs carry and sum.
Block diagram
Circuit Diagram
Full Adder
Full adder is developed to overcome the drawback of Half Adder circuit. It
can add two one-bit numbers A and B, and carry c. The full adder is a three
input and two output combinational circuit.
Block diagram
S=A⊕B⊕Cin
cout=AB+(A⊕B)cin
Circuit Diagram
This adder is called as Full adder because for implementing one Full
adder, we require two Half adders and one OR gate. If C in is zero, then Full
Prepared by : Dr.A.N. GnanaJeevan, Lect/Computer Page 40 of 53
adder becomes Half adder.
Half Subtractors
Half subtractor is a combination circuit with two inputs and two outputs
(difference and borrow). It produces the difference between the two binary
bits at the input and also produces an output (Borrow) to indicate if a 1 has
been borrowed. In the subtraction (A-B), A is called as Minuend bit and B is
called as Subtrahend bit.
Truth Table
Circuit Diagram
Full Subtractors
The disadvantage of a half subtractor is overcome by full subtractor. The
full subtractor is a combinational circuit with three inputs A,B,C and two
output D and C'. A is the 'minuend', B is 'subtrahend', C is the 'borrow'
produced by the previous stage, D is the difference output and C' is the
borrow output.
Truth Table
Prepared by : Dr.A.N. GnanaJeevan, Lect/Computer Page 41 of 53
Circuit Diagram
Block diagram
The parity generating technique is one of the most widely used error detection techniques for
the data transmission. In digital systems, when binary data is transmitted and processed, data
may be subjected to noise so that such noise can alter 0s (of data bits) to 1s and 1s to 0s.
Hence, parity bit is added to the word containing data in order to make number of 1s either
even or odd. Thus it is used to detect errors during the transmission of binary data .The
message containing the data bits along with parity bit is transmitted from transmitter node to
receiver node. At the receiving end, the number of 1s in the message is counted and if it
doesn’t match with the transmitted one, then it means there is an error in the data.
Parity Generator
It is combinational circuit that accepts an n-1 bit stream data and generates the additional bit
that is to be transmitted with the bit stream. This additional or extra bit is termed as a parity
bit. In even parity bit scheme, the parity bit is ‘0’ if there are even number of 1s in the data
stream and the parity bit is ‘1’ if there are odd number of 1s in the data stream. In odd
parity bit scheme, the parity bit is ‘1’ if there are even number of 1s in the data stream and
the parity bit is ‘0’ if there are odd number of 1s in the data stream. Let us discuss both even
and odd parity generators.
From the above truth table, the simplified expression of the parity bit can be written as
The above expression can be implemented by using two Ex-OR gates. The logic diagram of
even parity generator with two Ex – OR gates is shown below. The three bit message along
with the parity generated by this circuit which is transmitted to the receiving end where parity
The truth table of the odd parity generator can be simplified by using K-map as
P = (A ⊕ B ⊕C)’
Parity Check
It is a logic circuit that checks for possible errors in the transmission. This circuit can be an
even parity checker or odd parity checker depending on the type of parity generated at the
transmission end. When this circuit is used as even parity checker, the number of input bits
must always be even. When a parity error occurs, the ‘sum even’ output goes low and ‘sum
odd’ output goes high. If this logic circuit is used as an odd parity checker, the number of
input bits should be odd, but if an error occurs the ‘sum odd’ output goes low and ‘sum even’
output goes high.
The above logic expression for the even parity checker can be implemented by using three
Ex-OR gates as shown in figure. If the received message consists of five bits, then one more
Ex-OR gate is required for the even parity checking.
The expression for the PEC in the above truth table can be simplified by K-map as
The expression for the odd parity checker can be designed by using three Ex-NOR gates as shown
below.