Number Systems Digital Logic and Microprocessor

PRADEEPAM9 65 views 76 slides Jul 28, 2024
Slide 1
Slide 1 of 76
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76

About This Presentation

Number Systems Digital Logic and Microprocessor


Slide Content

Number Systems

Common Number Systems

System

Base

Symbols
Used by
humans?
Used in
computers?
Decimal 10 0, 1, … 9 Yes No
Binary 2 0, 1 No Yes
Octal 8 0, 1, … 7 No No
Hexa-
decimal
16 0, 1, … 9,
A, B, … F
No No

Quantities/Counting (1 of 3)

Decimal

Binary

Octal
Hexa-
decimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7

Quantities/Counting (2 of 3)

Decimal

Binary

Octal
Hexa-
decimal
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F

Quantities/Counting (3 of 3)

Decimal

Binary

Octal
Hexa-
decimal
16 10000 20 10
17 10001 21 11
18 10010 22 12
19 10011 23 13
20 10100 24 14
21 10101 25 15
22 10110 26 16
23 10111 27 17 Etc.

Conversion Among Bases
•The possibilities:
Hexadecimal
Decimal Octal
Binary

Quick Example
25
10 = 11001
2 = 31
8 = 19
16
Base

Decimal to Decimal (just for fun)
Hexadecimal
Decimal Octal
Binary

125
10 => 5 x 10
0
= 5
2 x 10
1
= 20
1 x 10
2
= 100
125
Base
Weight

Decimal Number System
•Decimal number system has only ten (10)
digits from 0 to 9. Every number (value)
represents with 0,1,2,3,4,5,6, 7,8 and 9 in
this number system. The base of decimal
number system is 10, because it has only 10
digits.

DECIMAL TO OTHER
•Decimal Number System to Other Base
•To convert Number system from Decimal
Number System to Any Other Base is quite
easy; you have to follow just two steps:
• A) Divide the Number (Decimal Number) by the
base of target base system (in which you want to
convert the number: Binary (2), octal (8) and
Hexadecimal (16)).
•B) Write the remainder from step 1 as a Least
Signification Bit (LSB) to Step last as a Most
Significant Bit (MSB)

Decimal Number System
•A repeated division and remainder
algorithm can convert decimal to
binary, octal, or hexadecimal.
•Divide the decimal number by the desired
target radix (2, 8, or 16).
•Append the remainder as the next most
significant digit.
•Repeat until the decimal number has
reached zero

Decimal to Binary
Hexadecimal
Decimal Octal
Binary

Decimal to Binary
A) Convert the integral part of decimal to
binary equivalent
-Divide by two, keep track of the remainder
•Repeat until the decimal number has
reached zero or less than 1

Example
125.47
10 = ?
2
2 125
62 1
2
31 0
2
15 1
2
7 1
2
3 1
2
1 1
2
0 1

125
10 = 1111101
2

B) Convert the fractional part of decimal to
binary equivalent
•Multiply the fractional decimal number by
2.
•Integral part of resultant decimal number
will be first digit of fraction binary number.
•Repeat step 1 using only fractional part of
decimal number and then step 2.

Example
•Step 2: .47
•Conversion of .47 to binary
•0.47 * 2 = 0.94, Integral part: 0 fractional part is not equal to 0 so we
copy it to next step
•0.94 * 2 = 1.88, Integral part: 1 fractional part is not equal to 0 so we
copy it to next step
•0.88 * 2 = 1.76, Integral part: 1 fractional part is not equal to 0 so we
copy it to next step
•0.76*2 = 1.52,Ingral part :1 fractional part is not equal to 0 so we
copy it to next step
•0.52*2=1.14,Integral Part:1 fractional part is not equal to 0 so we copy
it to next step
•in this case, we have 5 digits as answer and the fractional part is still
not 0 so, we stop here.
•So equivalent binary of fractional part of decimal
is .01111

•C) Combine both integral and fractional
part of binary number.
•125.47
10 = 1111101. 01111
2

Decimal to Octal
Hexadecimal
Decimal Octal
Binary

Decimal to Octal
•Technique
–Divide by 8
–Keep track of the remainder
•Repeat until the decimal number has
reached zero or less than 8

Example
•Convert decimal number 1234.16 into octal
form

Example
1234
10 = ?
8
8 1234
154 2 8
19 2 8
2 3 8
0 2
1234
10 = 2322
8

Example
•16
10
•Step 1
•We multiply 0.16 by 8 and take the integer part 0.16 x 8 =
1.28 Integer part = 1 Fractional part = 0.28 As, fractional
part is not equal to 0 so we copy it to next step. Step 2
• We multiply 0.28 by 8 and take the integer part 0.28 x 8 =
2.24 Integer part = 2 Fractional part = 0.24 As, fractional
part is not equal to 0 so we copy it to next step

•. Step 3
• We multiply 0.24 by 8 and take the integer
part 0.24 x 8 = 1.92 Integer part = 1
Fractional part = 0.92 As, fractional part is
not equal to 0 so we copy it to next step.
•Step 4 ---------- We multiply 0.92 by 8 and
take the integer part 0.92 x 8 = 7.36 Integer
part = 7 Fractional part = 0.36 As, fractional
part is not equal to 0 so we copy it to next
step.

•Step 5 ---------- We multiply 0.36 by 8 and
take the integer part 0.36 x 8 = 2.88 Integer
part = 2 Fractional part = 0.88 As, fractional
part is not equal to 0 so we copy it to next
step. Step 6 ---------- We multiply 0.88 by 8
and take the integer part 0.88 x 8 ...
•in this case, we have 5 digits as answer and
the fractional part is still not 0 so, we stop
here.

•C) Combine both integral and fractional
part of binary number.
•1234.16
10=2322.12172
8

Decimal to Hexadecimal
Hexadecimal
Decimal Octal
Binary

Decimal to Hexadecimal
•Technique
–Divide by 16
–Keep track of the remainder
- Repeat until the decimal number has
reached zero or less than 16

Example
1234.12
10 = ?
16
1234
10 = 4D2
16
16 1234
77 2 16
4 13 = D 16
0 4

Example
•12
10
•Step 1
•We multiply 0.12 by 16 and take the integer part 0.12x 16
= 1.92 Integer part = 1 Fractional part = 0.92 As, fractional
part is not equal to 0 so we copy it to next step. Step 2
• We multiply 0.92 by 16 and take the integer part 0.92 x 16
= 14.72 Integer part = 14-E Fractional part = 0.72 As,
fractional part is not equal to 0 so we copy it to next step
•.72*16=11.52, Integer part = 11-B Fractional part = 0.52
•.52*16=8.32, Integer part = 8, Fractional part = 0.32,……

•C) Combine both integral and fractional
part of binary number.
•1234.12
10 = 4D2.1EB8
16

Binary to Decimal
Hexadecimal
Decimal Octal
Binary

Binary to Decimal
•Technique
–Multiply each bit by 2
n
, where
n is the “weight” of the bit
–The weight is the position of
the bit, starting from 0 on the
right
–Add the results

Example
101011
2 => 1 x 2
0
= 1
1 x 2
1
= 2
0 x 2
2
= 0
1 x 2
3
= 8
0 x 2
4
= 0
1 x 2
5
= 32
43
10

Binary to Octal
Hexadecimal
Decimal Octal
Binary

Binary to Octal
•Technique
–Group bits in threes, starting
on right
–Convert to octal digits

Example
1011010111.1101101
2 =
?
8
110 110 100

6 6 4

1011010111.1101101
2 = 1327.664
8
Integral part
1 011 010 111

1 3 2 7

fractional part

Binary to Hexadecimal
Hexadecimal
Decimal Octal
Binary

Binary to Hexadecimal
•Technique
–Group bits in fours, starting
on right
–Convert to hexadecimal
digits

Example
1010111011.110001111
2 = ?
16
0010 1011 1011

2 B B

1010111011
2 = 2BB.C78
16
Integral part
fractional part
1100 0111 1000

C 7 8

Octal to Decimal
Hexadecimal
Decimal Octal
Binary

Octal to Decimal
•Technique
–Multiply each bit by 8
n
, where n
is the “weight” of the bit
–The weight is the position of the
bit, starting from 0 on the right
–Add the results

Example
724.123
8 =>4 x 8
0
= 4
2 x 8
1
= 16
7 x 8
2
= 448
468
10
123  1 x 8
-1
= 0.125
2 x 8-2 = 0.03125
3 x 8-
3
= 0.005859375
468.162109375
10

724.123
8 =>
0.162109375

Hexadecimal to Decimal
Hexadecimal
Decimal Octal
Binary

Hexadecimal to Decimal
•Technique
–Multiply each bit by 16
n
, where n is the
“weight” of the bit
–The weight is the position of the bit, starting
from 0 on the right
–Add the results

Example
ABC.1A
16 =>C x 16
0
= 12 x 1 = 12
B x 16
1
= 11 x 16 = 176
A x 16
2
= 10 x 256 = 2560
2748
10
ABC.1A
16 =>1 x 16
-1
= 0.0625
A x 16-
2
= 0.0390625
0.1015625
10
Ans. 2748.1015625
10

Octal to Binary
Hexadecimal
Decimal Octal
Binary

Octal to Binary
•Technique
–Convert each octal digit to a
3-bit equivalent binary
representation

Example
705
8 = ?
2
7 0 5

111 000 101
705
8 = 111000101
2

Hexadecimal to Binary
Hexadecimal
Decimal Octal
Binary

Hexadecimal to Binary
•Technique
–Convert each hexadecimal digit to a 4-bit
equivalent binary representation

Example
10AF
16 = ?
2
1 0 A F

0001 0000 1010 1111
10AF
16 = 0001000010101111
2

Octal to Hexadecimal
Hexadecimal
Decimal Octal
Binary

Octal to Hexadecimal
•Technique
–Use binary as an intermediary

Example
1076
8 = ?
16
1 0 7 6

001 000 111 110

2 3 E
1076
8 = 23E
16

Hexadecimal to Octal
Hexadecimal
Decimal Octal
Binary

Hexadecimal to Octal
•Technique
–Use binary as an intermediary

Example
1F0C
16 = ?
8
1 F 0 C

0001 1111 0000 1100

1 7 4 1 4
1F0C
16 = 17414
8

Exercise – Convert ...

Decimal

Binary

Octal
Hexa-
decimal
33
1110101
703
1AF

Exercise – Convert …

Decimal

Binary

Octal
Hexa-
decimal
33 100001 41 21
117 1110101 165 75
451 111000011 703 1C3
431 110101111 657 1AF
Answer

Common Powers (1 of 2)
•Base 10
Power Preface Symbol
10
-12
pico p
10
-9
nano n
10
-6
micro 
10
-3
milli m
10
3
kilo k
10
6
mega M
10
9
giga G
10
12
tera T
Value
.000000000001
.000000001
.000001
.001
1000
1000000
1000000000
1000000000000

Common Powers (2 of 2)
•Base 2
Power Preface Symbol
2
10
kilo k
2
20
mega M
2
30
Giga G
Value
1024
1048576
1073741824
• What is the value of “k”, “M”, and “G”?
• In computing, particularly w.r.t. memory,
the base-2 interpretation generally applies

Example
/ 2
30
=
In the lab…
1. Double click on My Computer
2. Right click on C:
3. Click on Properties

Exercise – Free Space
•Determine the “free space” on all drives on
a machine

Drive
Free space
Bytes GB
A:
C:
D:
E:
etc.

Review – multiplying powers
•For common bases, add powers
2
6
 2
10
= 2
16
= 65,536

or…

2
6
 2
10
= 64  2
10
= 64k
a
b
 a
c
= a
b+c

Binary Addition (1 of 2)
•Two 1-bit values
A B A + B
0 0 0
0 1 1
1 0 1
1 1 10
“two”

Binary Addition (2 of 2)
•Two n-bit values
–Add individual bits
–Propagate carries
–E.g.,
10101 21
+ 11001 + 25
101110 46
1 1

Multiplication (1 of 3)
•Decimal (just for fun)
35
x 105
175
000
35
3675

Multiplication (2 of 3)
•Binary, two 1-bit values
A B A  B
0 0 0
0 1 0
1 0 0
1 1 1

Multiplication (3 of 3)
•Binary, two n-bit values
–As with decimal values
–E.g.,
1110
x 1011
1110
1110
0000
1110
10011010

Fractions
•Decimal to decimal (just for fun)
3.14 => 4 x 10
-2
= 0.04
1 x 10
-1
= 0.1
3 x 10
0
= 3
3.14

Fractions
•Binary to decimal
10.1011 => 1 x 2
-4
= 0.0625
1 x 2
-3
= 0.125
0 x 2
-2
= 0.0
1 x 2
-1
= 0.5
0 x 2
0
= 0.0
1 x 2
1
= 2.0
2.6875

Fractions
•Decimal to binary
3.14579
.14579
x 2
0.29158
x 2
0.58316
x 2
1.16632
x 2
0.33264
x 2
0.66528
x 2
1.33056
etc. 11.001001...

Exercise – Convert ...
Don’t use a calculator!

Decimal

Binary

Octal
Hexa-
decimal
29.8
101.1101
3.07
C.82
Skip answer Answer

Exercise – Convert …

Decimal

Binary

Octal
Hexa-
decimal
29.8 11101.110011… 35.63… 1D.CC…
5.8125 101.1101 5.64 5.D
3.109375 11.000111 3.07 3.1C
12.5078125 1100.10000010 14.404 C.82
Answer

Thank you
Tags