Sei sulla pagina 1di 78

NUMBER SYSTEMS

DIGITAL LOGIC DESIGN (EC – 203)


Introduction

 The most commonly used Number Systems are :


 Decimal(Base 10)
 Binary (Base 2)
OOctal ((Base 8))
 Hexadecimal (Base 16)

 The decimal system is the one which we use


everyday
d
Number System
 Decimal
D i l system uses symbols b l (digits)
(di i ) for
f the
h ten values
l
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
 Bi
Binary S t
System uses digits
di i for
f the
th two
t valuesl 0 and
0, d1
 Octal System uses digits for the eight values 0, 1, 2, 3,
4 5,
4, 5 6,
6 7
 Hexadecimal System uses digits for the sixteen values
0 1,
0, 1 2,
2 3,
3 4,
4 5,
5 6,
6 7,
7 8,
8 9,
9 A,
A B,
B C,
C D,D E,
E F

to represent any number,


b no matter how
h l
large or how
h
small.
Number System Cont…
Decimal System

 The decimal system is composed of 10 numerals or


symbols. These 10 symbols are 0,1,2,3,4,5,6,7,8,9;
using these symbols as digits of a number, we can
express any quantity.
 Example : 3501.51

3 5 0 1 . 5 1
digit
Most Significant Least
Digit decimal point Significant Digit
Binary System

 The binary system is composed of 2 numerals or


symbols 0 and 1; using these symbols as digits of a
number, we can express any quantity.
 Example
p : 1101.01

1 1 0 1 . 0 1
bit
Most Significant Least
Bit binary point Significant Bit
Decimal Number Quantity
(
(positional
l number)
b )
 3501 (base-10)

1 X 100 = 1

0 X 101 = 0
5 X 102 = 500
3 X 103 = 3000

3000 + 500 + 0 + 1 = 3501


Binary-to-Decimal
Binary to Decimal Conversion

 1101 (base-2)

1 X 20 = 1

0 X 21 = 0
1 X 22 = 4
1 X 23 = 8
8 + 4 + 0 + 1 = 13
11012= 1310
Octal-to-Decimal
Octal to Decimal Conversion

 5217 (base-8)

7 X 80 = 7x1
7 1 = 7

1 X 81 = 1x8 = 8
2 X 82 = 2x64 = 128
5 X 83 = 5x512 = 2560
2560 + 128 + 8 + 7 = 2703
52178 = 270310
Hexadecimal-to-Decimal
Hexadecimal to Decimal Conversion

 1ACF (base-16) [ A = 10, B = 11, C = 12, D = 13, E = 14, F = 15 ]

15 X 160 =15x1
15 1 = 15

12 X 161 =12x16 = 192


10 X 162 =10x256 = 2560
1 X 163 = 5x4096 = 20480
20480 + 2560 +192 + 15 = 23247
1ACF16 = 2324710
Decimal Number Quantity
(f
(fractional
l number)
b )
 . 581 (base-10)

5 X 10-11 = 5x0.1
5 01 = 0.5
05

8 X 10-22 = 8x0.01
8x0 01 = 0.08
0 08
1 X 10-3 = 1x0.001 = 0.001

0.5 + 0.08 + 0.001 = 0.581


Binary-to-Decimal
Binary to Decimal Conversion

 . 101 (base-2)

1 X 2-11 = 1x0.5
1 05 = 0.5
05

0 X 2-22 = 0x0.25
0x0 25 = 0
1 X 2-3 = 1x0.125 = 0.125

0.5 + 0 + 0.125 = 0.625

0.1012 = 0.62510
Octal-to-Decimal
Octal to Decimal Conversion

 . 25 (base-8)

2 X 8-11 = 2x0.125
2 0 125 = 0.25
0 25

5 X 8-2 = 5x0.015625
5 0 015625 =
0.017825

0.25 + 0.017825 = 0.267825

0.258 = 0.26782510
Hexadecimal-to-Decimal
Hexadecimal to Decimal Conversion

 . F5 (base-16)

15 X16-11 = 15x0.0625 =
0.9375
5 X16-2 = 5x0.00390625
5 0 00390625
= 0.01953125

0.9375 + 0.01953125 = 0.95703125

0.F516 = 0.9570312510
Exercise 1

 Convert these binary system numbers to decimal


system numbers
 100101101

 11100.1001
 111111

 100000.0111
100000 0111
Decimal-to-Binary Conversion
(
(positional
l number)
b )
 250 25010 = 1 1 1 1 1 0 1 02
2 250
2 125 Remainder 0
2 62 Remainder 1
2 31 Remainder 0
2 15 R
Remainder
i d 1
2 7 Remainder 1
2 3 Remainder 1
1 Remainder 1
Decimal-to-Octal
Decimal to Octal Conversion

 250
8 250
8 31 Remainder 2
3 Remainder 7

25010 = 3728
Decimal-to-Hexadecimal
Decimal to Hexadecimal Conversion

 250
16 250
15 Remainder 10

25010 = 15 1016 ?
= FA16
Decimal-to-Binary Conversion
(f
(fractional
l number)
b )
 0 . 4375
0.4375
0 4375 x 2 = 0.8750
0 8750
0.8750 x 2 = 1.75
0 75 x 2
0.75 = 15
1.5
0.5 x2 = 1.0

0 437510 = 0.0111
0.4375 0 01112
Decimal-to-Octal
Decimal to Octal Conversion

 0 . 4375
0.4375
0 4375 x 8 = 3.5
35
0.5 x8 = 4.0

0 437510 = 0.34
0.4375 0 348
Decimal-to-Hexadecimal
Decimal to Hexadecimal Conversion

 0 . 4375
0 4375 x 16
0.4375 = 7.0
70

0 437510 = 0.7
0.4375 0 716
Exercise 2

 Convert these decimal system numbers to binary


system numbers
 127

 38
 22.5

 764.375
764 375
Base X – to – Base Y Conversion

 We can convert base x number to base y number


by following these steps :
 Convert base x to base 10 (decimal system number)
 Then, convert decimal number to base y
Example

 Convert 372.348 to hexadecimal system number


 Convert 372.348 to decimal system number
 372.348 = (3x82)+(7x81)+(2x80) . (3x8-1) + (4x8-2)
= 192 + 56 + 2 . 0.375 + 0.0625
= 250 . 4375
 Convert 250.437510 to hexadecimal system number
 250.437510
Positional number Fractional number
250 / 16 = 15 remainder 10 0.4375 * 16 = 7.0
250  FA16 0.4375  0.716

372.348 = FA.716
Exercise 3 (TODO)

 Convert these numbers to octal system number


 11100.10012
 1111112

 5A.B16

 Convert these numbers to binary system number


 5A.B
5A B16
 75.28
Binary Addition Rules
 0+0 = 0
 0+1 = 1
 1+0 = 1
 1+1 = 0 with
ith a carry off 1 to
t th
the nextt significant
i ifi t bit
 1+1+1 = 1 with a carry of 1 to the next significant
bit
Binary Subtraction Rules
 0–0=0
 1–0=1
 1–1=0
 0 – 1 = 1 with
ith a b
borrow off 1 from
f the
th immediate
i di t
significant bit
Add the Following
Solution
Solution
Binary to Octal/Hex & Vice Versa
Binary Multiplication
 Repeated Left Shift and Add Method
Repeated Add and Right Shift
Binary Multiplication
 Repeated ADD and Right Shift (Used by Microprocessors)
Binary Division
Octal Addition & Subtraction
Octal Multiplication
Octal Division
Hexadecimal Addition
Hexadecimal Subtraction
Hexadecimal Multiplication
Hexadecimal Division
Digital Codes
Digital Codes Cont…
 Weighted Codes: In weighted codes each binary
bit is assigned by a weight and values depend on
the
h position
i i off the
h binary
bi bi The
bit. Th BCD code
d has
h a
weight of 8, 4, 2 and 1.
 Eg.
E A) 8421 Code
C d and
d B) 84-2-1
84 2 1
 Non-Weighted Codes: In this category of digital
code, no specific weights are assigned to the bit
position. Each digit position within the number is not
assigned
i d fixed
fi d value.
l N
Non-weighted
i h d codes
d are off
two types.
 Eg.
E A) Excess-3
E 3 B) Gray
G C d
Code
Digital Codes Cont…
 Reflective Codes: A code is said to be
reflective when the code is self complementing. In
other
h words,d when
h theh coded for
f 9 is i the
h complement
l
the code for 0, 8 for 1, 7 for 2, 6 for 3 and 5 for 4.
 Eg.
E A) 2421 Code
C d and
d B) Excess-3
E 3
 Sequential Codes: In sequential codes, each
succeeding code is one binary number greater than
its preceding code. In Ex-3 code each decimal digit
i obtained
is b i d by b adding
ddi decimal
d i l 3 to theh naturall code
d
of the digit. The sequential codes are:
 Eg.
E A) Excess
E - 3 B) 8421 Code
C d
Digital Codes Cont…
 Al h
Alphanumeric
i Codes:
C d
 A) ASCII (American Standard Codes for Information Interchange)
 B) EBCDIC (Extended Binary Coded Decimal Interchanged Code)
 Error Detecting and Correcting Codes: Binary information, be
it pulse-modulated signals or digital computer input or
output,
t t may be b transmitted
t itt d through
th h some formf off
communication medium such as wires or radio waves. Any
external noise introduced into a physical communication
medium changes bit values from 0 to 1 or vice versa. An
error-detection code can be used to detect errors during
transmission. The detected error cannot be corrected,, but its
presence is indicated.
 A) Parity Code
 B) Hamming
H i Code
C d
Digital Codes Cont…
 Gray Code: The gray code was designed by Frank
Gray at Bell Labs in 1953. It is an un-weighed
binary code in which two successive value differ only
byy one bit. Grayy code is the special
p case of unit-
distance code. In unit distance code, bit patterns for
two consecutive numbers differ in only y bit pposition.
These codes are also called Cyclic Code.
Digital Codes Cont…
 ASCII Code: The ASCII code is used for the transfer
of alphanumeric information between a computer
and input/output devices such as monitors or
printers. A computer
p p also uses it internally
y to store
the information that an operator types in at the
computer’s
p keyboard.
y The ASCII code p pronounced
“askee is a seven-bit code, and so it has 27 (=128)
possible code g
p groups.
p
Concept Check
 Represent the decimal number 27
 A) Binary
 B) ASCII

 C) G
Grayy
 D) Excess - 3
rr’ss Complement

 Given a positive number N in base r with an integer


part of n digits,
p g , the r’s complement
p of N is defined
as r  N for N ≠ 0 and 0 for N = 0.
n

 Eg
Eg.
(r-1)’s
(r 1) s Complement
 Given a positive number N in base r with an integer
part of n digits and a fraction part of m digits, the
(r – l)’s complement of N is defined as r  r  N
n m
1’ss Complement
1
2’ss Complement
2
Concept Check
Signed Number Concept
Signed Number Concept Cont…
Concept Check
Solution
Solution
Solution
Subtraction with rr’ss Complement
 The subtraction of two positive numbers (M-N), both
of base r, may be done as follows:
 Add the minuend M to the r’s complement of the
subtrahend N.
 Inspect the result obtained in step 1 for an end carry:
 If an end carry occurs, discard it.
 If an end carry does not occur, take the r’s complement of
the number obtained in step 1 and place a negative sign in
front.
Subtraction with (r
(r-1)’s
1) s Complement
 The subtraction of two positive numbers (M-N), both
of base r, may be done as follows:
 Add the minuend M to the (r-1)’s complement of the
subtrahend N.
 Inspect the result obtained in step 1 for an end carry:
 If an end carry occurs, add 1 to the least significant digit
(end-around carry).
 If an end carry does not occur, take the (r-1)’s complement
off the
h number
b obtained
b d in step 1 and
d place
l a negative sign
in front.
Overflow Condition
To Be Continued...
Continued

Potrebbero piacerti anche