Lecture 4- Number System - Copy
Lecture 4- Number System - Copy
Department of Computing
Shifa Tameer-e-Millat University
(STMU). 1
Digital Data Representation
A well known example of digital data is finite integer representation using Decimal Number
system
Decimal Number System
It has Base 10
A number base is the total number of digits that a system of counting uses
to higher numbers
Decimal number system contains 10 numbers (0,1,2,…, 9) that are used to
represent any other number
Decimal number system is a positional number system in which every
number greater
than 9 is represented as sum of products
2
Introduction
3
Number System
Decimal system uses 10 symbols
(digits)
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Octal System uses eight symbols
0, 1, 2, 3, 4, 5, 6, 7
Binary System uses only two
symbols
0 and 1
Hexadecimal System uses sixteen
symbols
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D,
E, F
• Base (radix) = 10
– 10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8,
9 } Position
• Digit 2 1 0 -1 -2
– Integer & fraction
4 1 5 4 4
• Digit Weight
100 10 1 0.1 0.01
– Weight = (Base) Position
• Formal (415.44)10
Notation
5
Decimal System
3 5 0 1 . 5 1
digit
Most Least
Significant decimal Significant
Digit point Digit 7
Binary Number System
• Base (radix) = 2
– 2 digits { 0, 1 }, also called
“bits”
• Weights 4 2 1 1/2 1/4
– Weight = (Base) Position 1 0 1 0 1
– Weight = (2) Position 2 1 0 -1 -2
• Magnitude
1 *22+0 *21+1 *20+0 *2-1+1 *2-2
– Sum of “Bit x Weight”
=(5.25) 10
• Formal Notation
(101.01)2
• Groups of bits
– 4 bits = {1 0 1 1}
Nibble {1 1 0 0 0 1 0 1}
– 8 bits = Byte {1 1 0 0 0 1 0 1 1 1 0 1 0 1 0
– 16 bits = 0} 8
Binary System
1 1 0 1 . 0 1
bit
Most Least
Significant binary Significant
Bit point Bit 9
Octal Number System
• Base (radix) = 8
– 8 digits { 0, 1, 2, 3, 4, 5, 6,
7} 64 8 1 1/8 1/64
• Weights
5 1 2 7 4
– Weight = (Base) Position
2 1 0 -1 -
– Weight = (8) Position 2
9
Hexadecimal Number System
• Base (radix) = 16
– 16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E,
F}
256 16 1 1/16 1/256
• Weights
– Weight = (Base) Position
10
Number Systems
• Decimal Numbers Decimal Binary Octal Hex
– 10 Digits 00 0000 00 0
• Binary Numbers 01 0001 01 1
02 0010 02 2
– 2 Digits/Bits 03 0011 03 3
• Octal Numbers 04 0100 04 4
– 8 Digits 05 0101 05 5
06 0110 06 6
• Hexadecimal 07 0111 07 7
Numbers 08 1000 10 8
– 16 Digits 09 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
11
Familiar
System
Octal System Hexa decimal Decimal Binary Base 4
(Base – 8 ns) Number Number Equivale number
System (Base (Base- nt (Base- System
– 16) 10) 2) (Base -4)
0 0 0 0 0
1 1 1 1 1
2 2 2 10 2
3 3 3 11 3
4 4 4 100 10
5 5 5 101 11
6 6 6 110 12
7 7 7 111 13
10 8 8 1000 20
11 9 9 1001 21
12 A 10 1010 22
13 B 11 1011 23
14 C 12 1100 30
15 D 13 1101 31
16 E 14 1110 32
17 F 15 1111 33
Number Systems
Decimal 10 0,1,2,…,9
Binary 2 0,1
Octal 8 0,1,2,…,8
Hexadecimal 16 0,1,..9,A,B,C,D,E,F
13
Bits, Bytes, Nibbles
Bits 1001011
(b) 0
most least
significan significan
t bit t bit
byt
Bytes & Nibbles e
Nibble (N) = 4
bits
Not commonly CEBF9AD
used 7
most least
significa significa
nt byte nt byte
14
KB, MB, GB …
350 (base-
1 10)
1 X 100 1
=
0 X
101
= 0
5 X
102
16
=
Binary-to-Decimal Conversion
110 (base-
1 2)
1 = 1
X = 0
= 4
20
= 8
0
X
17
Digital Data Representation
Binary to Integer Number Conversion
100112 = (?)10
= (1 x 24) + (0 x 23) + (0 x 22) + (1 x 21)+ (1 x 20)
= (1 x 16) + (0 x 8) + (0 x 4) + (1 x 2) + (1 x 1)
= 16 + 0 + 0 + 2 + 1
= 1910
18
Octal-to-Decimal Conversion
521 (base-
7 8)
7 = 7x1 =X 870
1 = 1x8 =X 881
2 = 2x6 =X 128
82
4
5 X 83
= 5x512 = 2560
2560 + 128 + 8 + 7 = 2703
52178 = 270310 19
Hexadecimal-to-Decimal Conversion
.10 (base-
1 2)
1 X 2- = =
1 1x0.5 0.5
0 X 2-2 =
0x0.25 =0
1 X 2-3 =
1x0.125 = 0.125
0.1012 = 0.62510 22
Octal-to-Decimal Conversion
.2 (base-
5 8)
2 X 8- = =
1 2x0.125 0.25
5 X 8-2 =
5x0.015625 =
0.017825
0.258 = 0.26782510
23
Hexadecimal-to-Decimal Conversion
. F (base-
5 16)
15 X16-1
= 15x0.0625 =
0.9375
5 X16-2
= 5x0.00390625
= 0.01953125
28
Decimal-to-Binary Conversion(positional number)
25 25010 = 1 1 1 1 1 0
0 2 1 02
250 Remainder
Remainder 0
22 1
Remainder
125
62
2 0
Remainder
31 1
Remainder 1
22 15
7
Remainder 1
2 3
1 Remainder 1
29
Decimal to Binary Conversion
Answer: = (0.001)2
30
Decimal-to-Octal Conversion
25
0 8
250 Remainder 2
8 3 Remainde 7
31 r
25010 =
3728
31
Decimal-to-Hexadecimal Conversion
250
16
1 Remainde 1
250 5 r 0
25010 = 15
1016 ?
= FA16
32
Decimal-to-Binary Conversion(fractional
number)
0.
4375
0.4375 x 2 = 0.875
0
0.8750 x 2 = 1.75
0.75 x 2 = 1.5
0.5 x2 = 1.0
0.437510 =
0.01112
33
Decimal-to-Octal Conversion
0.
4375
0.4375 x 8 = 3.5
0.5 x8 = 4.0
0.437510 = 0.348
34
Decimal-to-Hexadecimal Conversion
0 . 4375
0.4375 x =
16 7.0
0.437510 = 0.716
35
Example :Decimal-to-Binary Conversion(Estimation)
38
Number Base Conversions : Practice Questions
39
Exercise 2
0.5 x 2 = 1.0
=> (22.5)10=(
10110.1 )2 40
BaseX– to – BaseY Conversion
41
Number Base Conversions
Sum of
(Digit x Weight)
Octal
(Base
8)
Sum of
(Digit x Weight)
?
Decimal Binary
(Base (Base
10) 2)
Hexadecimal
(Base 16)
9/16/2020
23 43
Octal to Hexadecimal
• Convert to Binary as an intermediate step i.e.
Convert from Octal to Binary to Hexadecimal
Example: ( 2 6 . 2 )8
( 0 1 0 1 1 0 . 0 1 0 )2
(1 6 . 4
)16
Works both ways (Octal to Hex & Hex to Octal)
44
Example
45
Number Base Conversion :Binary, Octal, Hexadecimal to Decimal
1 0 1 0 1
8
1 *24+0 *23+1 *22+0 *21+1 *20
4
=(21)10
2 46
Number Base Conversion
(Decimal to Binary, Octal, Hexadecimal)
50