Ch1 Numbering System
Ch1 Numbering System
Part 2
Chapter 1
Data Representation and
Digital Logic
ITP3901 OPERATING SYSTEMS FUNDAMENTALS
(AY 2019/20)
2
Data Representations
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
3
Alphanumeric Codes
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
4
Alphanumeric Codes
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
5
Double-byte Character Set
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
6
Unicode
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
7
Numbering
System
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
8
Commonly used Numbering Systems
Binary number system (base 2), octal (base 8), and hexadecimal (base 16)
number systems.
Computers only deal with binary numbers, the use of the octal and
hexadecimal numbers is solely for the convenience of human people.
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
9
Numbering Systems in Computer
Binary (Base 2)
e.g. 1011112
Octal (Base 8)
e.g. 168 (Digit with value 0 -7)
Hexadecimal (or Hex - Base 16)
ABCDEF16 (Digit with value 0 – F)
How to convert between different base?
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
10
Conversion from decimal to binary
Example:
Convert 345 (in decimal) to binary
1 x 28 + 0 x 27 + 1 x 26 + 0 x 25 + 1 x 24 + 1 x 23 + 0 x 2 2 + 0 x 21 + 1 x 20
= 34510
Example
Octal to Decimal: Convert 5318 (oct) to decimal
Decimal representation of 5318
= 5 x 82 + 3 x 81 + 1 x 80
= 34510
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
12
Conversion from Binary to Octal
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
13
Conversion from Binary to Hexadecimal
Binary to Hexidecimal
0000 0
Conversion from binary to hex 0001 1
0010 2
1 0101 1001 0011 3
0100 4
1 5 9 => 159 (hex) 0101 5
0110 6
0111 7
1000 8
By using
1001 9
MOD 16 1010 A
1011 B
(MOD – find the remainder) 1100 C
1101 D
1110 E
1111 F
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
14
Conversion from decimal to octal or
hexadecimal
Example
Convert 34510 to octal representation
345 MOD 8 = 1 (345/8 = 43)
43 MOD 8 = 3 (43/8 = 5 )
5 MOD 8 = 5
Ans: 5318
Example
Convert 34510 to hexadecimal representation
345 MOD 16 = 9 (345/16 = 21)
21 MOD 16 = 5 (21/16 = 1 )
1 MOD 16 = 1
Ans: 15916
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
15
Negative numbers
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
16
Sign bit representation
= 001012 + 101012
= 11010 2
-1010
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
17
Complement representation
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
18
Complement representation
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
19
8-bit 1’s complement integers
1's complement
Bits Unsigned value
value
0111 1111 127 127
0111 1110 126 126
0000 0010 2 2
0000 0001 1 1
0000 0000 0 0
1111 1111 255 −0
1111 1110 254 −1
1000 0010 130 −125
1000 0001 129 −126
1000 0000 128 −127
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
20
2’s complement
= (2n - 1) - N2 + 1
= N’2 + 1
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
21
8-bit 2’s complement integers
2's complement
Bits Unsigned value
value
0111 1111 127 127
0111 1110 126 126
0000 0010 2 2
0000 0001 1 1
0000 0000 0 0
1111 1111 255 −1
1111 1110 254 −2
1000 0010 130 −126
1000 0001 129 −127
1000 0000 128 −128
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
22
Subtraction Example: 93 - 65
93 - 65
01011101 (+93) (X)
+ 10111111 (-65) (28 -Y)
1 00011100 (+28) (X-Y)
Overflow (28)
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
23
Subtraction Example: 65 - 93
65 - 93
01000001 (+65) (X)
+ 10100011 (-93) (-Y) → 28-Y
11100100 (-ve) 28-(Y-X)
100000000 28
- 11100100 28-(Y-X)
00011100 (28) (Y-X)
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
25
Floating-point numbers
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
26
Introduction to
Digital Logic
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
27
What is logic gate?
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
28
Logic Gates
AND Gate
OR Gate
XOR Gate
NOT Gate
NAND Gate
NOR Gate
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
29
Logic Gate - AND
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
30
Logic Gate - OR
OR Gate ( similar to ‘ + ‘)
x y output
0 0 0
0 1 1
1 0 1
1 1 1
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
31
Logic Gate - NOT
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
32
Logic Gate - XOR
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
33
Logic Gate - NAND
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
34
Logic Gate - NOR
Negated
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
35
Logic Gate – What you can find in
electronic components market
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
36
Integrated Circuits (IC)
12
[1] [1] [3]
13 [2]
[3] 8
1
2
[2]
We then have:
A
S
B
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals
38
CPU Chips
Chapter 1 - Data Representation & Digital Logic ITP3901 Operating Systems Fundamentals