0% found this document useful (0 votes)
42 views102 pages

Unit-I Number Systems and Binary Arithmetic

Uploaded by

omnikam0202
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)
42 views102 pages

Unit-I Number Systems and Binary Arithmetic

Uploaded by

omnikam0202
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/ 102

Basics of Digital Electronics

Unit-I Number Systems and Binary Arithmetic


[8]
Introduction to Decimal, Binary, Octal and Hexadecimal number systems and their
inter-conversions, Signed and fractional binary number representations, Binary Coded
Decimal, Gray Codes, Gray to Binary and Binary to Gray conversion, Alphanumeric
representation in ASCII codes. Rules of binary addition and subtraction, and subtraction
using 1’s and 2’s complements
Number System
• 12.34= 1*10^1+2*10^0+ 3*10^-1+2*10^-2
2=2*10^1=2*10=20
= 2*10^-1= 2/10=0.2
• (1000)2= (8)10
• (010)2 = (2)10
• (11011)2=(16+8+2+1)10 =(27)10
• (10110)2 = =(16+4+2)10=22
Binary number system
8421
1011
(5341)8=(?)2
8421=15
8421

• (1DE)16=( ?)2
8421
64 32 16 8421

• 64 32 16 8421
Questions
Convert the Given Decimal Number to Binary
Number:
1. 26210 2 262
131 0
a) 1001001012 65 1
32 1
b) 1000001012 16 0
8 0
c) 1000001102 4 0
2 0
d) 1100001102 1 0
0 1
e) 1100001012
100000110
• Steps :
• Divide the Given number by 2
• For the next iteration , get the quotient
• Get the remainder which is used to determine the binary number
• Repeat the steps until the iteration gets a 0 as quotient.
• Record the reminders from bottom to top

• Answer is : 1000001102
• (100)dec into bin

100
50 0
25 0
12 1
6 0
3 0
1 1
0 1

1100100
INTERCONVERSION :
As the computer and modern digital devices are not working on decimal we
need to convert it into binary
Possible number based
interconversions
• 100/8 = 12 4
• 12/8 = 1 4
• 1/8=0 1
(100)8=(1*8^2+0*8^1+0*8^0)10
1 101 010 101 = 001 101 010 101

1525

421
011

10110=? 010 110


421

• 76 111 110
• 54 101 100
• 64 110 100
0 to 9 & A TO F
8421
15=F=1111
8421
1E8=BIN?
125=0001 0010 0101
1234=
• 35 =38 0011 1000
00101101 = odd ========🡺1100 even

1 110 1110==========🡺
Summary
Gray to Binary and Binary to Gray
conversion
• Binary Numbers is default way to store numbers,
but in many applications binary numbers are
difficult to use and a variation of binary numbers
is needed. This is where Gray codes are very
useful.
• Gray code has property that two successive
numbers differ in only one bit because of this
property gray code does the cycling through
various states with minimal effort and used in
K-maps, error correction, communication etc.
XOR gate
• XOR gate (sometimes EOR, or EXOR and
pronounced as Exclusive OR) is a digital
logic gate that gives a true (1 or HIGH) output
when the number of two inputs is odd.
• Logic Gate: A circuit with n inputs and one
output.
• It will perform desired operation on input and
will produce the output.
Y= ~a*b+a*~b For n inputs,there
will be 2^n input
combinations.

2🡺4
3🡺 8
4🡺16
5=🡺32

21
0 00
1 01
2 10
3 11

Output of XOR gate


is 1 if input contains
odd number of 1’s

10110 ==?
0110
Binary to gray
• 1 0 1 1111🡺
• 1 0
• ---------------- 111
• 1 1 1
• -------------
• B2 B1 BO = G2 G1 G0
G2= B2 1000
G1=B2 XOR B1

G0= B1 XOR B0
110
------------
101
How to Convert Binary to Gray Code
• The MSB (Most Significant Bit) of the gray code will be
exactly equal to the first bit of the given binary
number.
• The second bit of the code will be exclusive-or (XOR) of
the first and second bit of the given binary number, i.e
if both the bits are same the result will be 0 and if they
are different the result will be 1.
• The third bit of gray code will be equal to the
exclusive-or (XOR) of the second and third bit of the
given binary number. Thus the binary to gray code
conversion goes on. An example is given below to
illustrate these steps
Gray to Binary Code Converter
• In a gray to binary code converter, the input is
gray code and output is its equivalent binary
code.
GRAY TO BIN
• G2 G1 G0 🡺 B2B1B0

b2 b1
-----------------------------
b2 b1 b0

1 0 1
1 1
------------
1 1 0
B2= G2
B1= G2 XOR G1
B0= B1 XOR G0= G2 XOR G1 XOR G0
1011 =🡺
• Example-1: Find 1’s complement of binary
number 10101110.
• Simply invert each bit of given binary number, so
1’s complement of given number will be
01010001.
• Example-2: Find 1’s complement of binary
number 10001.001.
• Simply invert each bit of given binary number, so
1’s complement of given number will be
01110.110.
Subtraction using 1’s COMPLEMENT
Subtractions by 1’s Complement:

11001-11100
10-4(0100)
1010
1011
----------------
0101
1
-------------------
0110
2’s Complement of a Binary Number
• To get 2’s complement of binary number is 1’s complement of
given number plus 1 to the least significant bit (LSB). For
example 2’s complement of binary number 10010 is (01101) +
1 = 01110.
• There is a simple algorithm to convert a binary number into
2’s complement. To get 2’s complement of a binary number,
simply invert the given number and add 1 to the least
significant bit (LSB) of given result.
• 10101110
• 01010001
• + 1
• -----------------
01010010
Subtractions by 2’s Complement
A= 11001
+
B=00100
…………….
111 01
1’S COMP: 00010
2’S COMP: 00011
Numbers with Fractions
Conversion of Decimal to Binary for
Mixed Number
• To convert a decimal mixed number into the
binary number, the same approach is used, as
was done in integer and fractional parts of the
number. Consider the decimal number 13.40.
• The binary equivalent of 13 is 1101, and the
binary equivalent of 0.40 is. 011001.
Therefore 1101.011001 is the required binary
number.
• We will understand how do we convert a decimal
number if there is decimal point involved in it.
Lets take 458.692
• It works the same way as above to deduce the
binary number for the given decimal number for
the integer part that is the number, which is
towards the left side of the decimal point or
before the decimal point.
• For the number that is after the decimal point or
the towards the right side of the decimal point,
start multiplying the fractional part including
decimal point by 2 until the first digit after decimal
point becomes 0.
Gray to Binary and Binary to Gray
conversion
• Binary Numbers is default way to store numbers,
but in many applications binary numbers are
difficult to use and a variation of binary numbers
is needed. This is where Gray codes are very
useful.
• Gray code has property that two successive
numbers differ in only one bit because of this
property gray code does the cycling through
various states with minimal effort and used in
K-maps, error correction, communication etc.
XOR gate
• XOR gate (sometimes EOR, or EXOR and
pronounced as Exclusive OR) is a digital
logic gate that gives a true (1 or HIGH) output
when the number of true inputs is odd.
Y= ~a*b+a*~b
How to Convert Binary to Gray Code
• The MSB (Most Significant Bit) of the gray code will be
exactly equal to the first bit of the given binary
number.
• The second bit of the code will be exclusive-or (XOR) of
the first and second bit of the given binary number, i.e
if both the bits are same the result will be 0 and if they
are different the result will be 1.
• The third bit of gray code will be equal to the
exclusive-or (XOR) of the second and third bit of the
given binary number. Thus the binary to gray code
conversion goes on. An example is given below to
illustrate these steps
Gray to Binary Code Converter
• In a gray to binary code converter, the input is
gray code and output is its equivalent binary
code.
2’s Complement of a Binary Number
• To get 2’s complement of binary number is 1’s complement of
given number plus 1 to the least significant bit (LSB). For
example 2’s complement of binary number 10010 is (01101) +
1 = 01110.
• There is a simple algorithm to convert a binary number into
2’s complement. To get 2’s complement of a binary number,
simply invert the given number and add 1 to the least
significant bit (LSB) of given result.
Subtractions by 2’s Complement
Additions by 2’s Complement −

You might also like