IT1016 Lesson2
IT1016 Lesson2
Computer Science
IT1016
Part I:
Fundamental of
Information Technology
2
Fundamental of Information Technology
Communication
Application
Operating system
Programming
Hardware
Data
3
Fundamental of Information Technology
4
Unit 2: Data representation in a computer
5
Number systems
• Decimal System
• Base-b System
• Binary System
• Hexadecimal System
• Octal System
6
Number systems
àBase 𝑏 = 𝟏𝟎
8
Decimal system
n→1
<latexit sha1_base64="OfKOMoQI4cpqvttIdUmbQChbNQM=">AAACC3icbVDLSsNAFJ3UV62vqEs3Q4vgxpKIVDdC0Y3LCvYBbRomk0k77WQSZiZCCdm78VfcuFDErT/gzr9x2mahrQcuHM65l3vv8WJGpbKsb6Owsrq2vlHcLG1t7+zumfsHLRklApMmjlgkOh6ShFFOmooqRjqxICj0GGl745up334gQtKI36tJTJwQDTgNKEZKS65Z7skkdNMRvIJW1k/5qZ1B3x3BnqIhkdC2+iPXrFhVawa4TOycVECOhmt+9fwIJyHhCjMkZde2YuWkSCiKGclKvUSSGOExGpCuphzpTU46+yWDx1rxYRAJXVzBmfp7IkWhlJPQ050hUkO56E3F/7xuooJLJ6U8ThTheL4oSBhUEZwGA30qCFZsognCgupbIR4igbDS8ZV0CPbiy8ukdVa1a9Xa3Xmlfp3HUQRHoAxOgA0uQB3cggZoAgwewTN4BW/Gk/FivBsf89aCkc8cgj8wPn8AlIqZfw==</latexit>
!
dj → 10j
à Its value is calculated by
j=0
n→1
<latexit sha1_base64="LvulUr3u+wHeU9KYXcvPda10Km8=">AAACDHicbVDLSgMxFM3UV62vqks3wSK4aZkRqW6EohuXFewDOtOSSTNt2iQzJBmhDPMBbvwVNy4UcesHuPNvTNtZaOuBwOGcc7m5x48YVdq2v63cyura+kZ+s7C1vbO7V9w/aKowlpg0cMhC2faRIowK0tBUM9KOJEHcZ6Tlj2+mfuuBSEVDca8nEfE4GggaUIy0kXrFkqti3ktG8AqWedpNRNlJYb83gq6mnCjo2N2RSdkVewa4TJyMlECGeq/45fZDHHMiNGZIqY5jR9pLkNQUM5IW3FiRCOExGpCOoQKZTV4yOyaFJ0bpwyCU5gkNZ+rviQRxpSbcN0mO9FAtelPxP68T6+DSS6iIYk0Eni8KYgZ1CKfNwD6VBGs2MQRhSc1fIR4iibA2/RVMCc7iycukeVZxqpXq3Xmpdp3VkQdH4BicAgdcgBq4BXXQABg8gmfwCt6sJ+vFerc+5tGclc0cgj+wPn8AZ6uZ8w==</latexit>
!
à Its value is calculated by dj → 10j
j=→m
9
Base 𝑏-system
n→1
<latexit sha1_base64="qWhTLxuqKRCRm1te5TYjVQXbc4Y=">AAACCnicbVDLSsNAFJ3UV62vqEs3o0VwY0lEqhuh6MZlBfuAJg2TyaSddjIJMxOhhKzd+CtuXCji1i9w5984fSy09cCFwzn3cu89fsKoVJb1bRSWlldW14rrpY3Nre0dc3evKeNUYNLAMYtF20eSMMpJQ1HFSDsRBEU+Iy1/eDP2Ww9ESBrzezVKiBuhHqchxUhpyTMPHZlGXjaAV9DKuxk/tXMYeAPoKBoRCf3uwDPLVsWaAC4Se0bKYIa6Z345QYzTiHCFGZKyY1uJcjMkFMWM5CUnlSRBeIh6pKMpR3qRm01eyeGxVgIYxkIXV3Ci/p7IUCTlKPJ1Z4RUX857Y/E/r5Oq8NLNKE9SRTieLgpTBlUMx7nAgAqCFRtpgrCg+laI+0ggrHR6JR2CPf/yImmeVexqpXp3Xq5dz+IoggNwBE6ADS5ADdyCOmgADB7BM3gFb8aT8WK8Gx/T1oIxm9kHf2B8/gBmUJl2</latexit>
!
à Its value is calculated by d j → bj Convert to
j=0 decimal
n→1
<latexit sha1_base64="vneXjcX2U/katai7f7XrQnq4JEU=">AAACC3icbVC7SgNBFJ31GeNr1dJmSBBsEnZFoo0QtLGMYB6QbJbZ2UkyyczsMjMrhCW9jb9iY6GIrT9g5984SbbQxAMXDufcy733BDGjSjvOt7Wyura+sZnbym/v7O7t2weHDRUlEpM6jlgkWwFShFFB6ppqRlqxJIgHjDSD0c3Ubz4QqWgk7vU4Jh5HfUF7FCNtJN8udFTC/XQIr2CJT7qpKLkTGPpD2NGUEwWD7tC3i07ZmQEuEzcjRZCh5ttfnTDCCSdCY4aUartOrL0USU0xI5N8J1EkRniE+qRtqEBmkZfOfpnAE6OEsBdJU0LDmfp7IkVcqTEPTCdHeqAWvan4n9dOdO/SS6mIE00Eni/qJQzqCE6DgSGVBGs2NgRhSc2tEA+QRFib+PImBHfx5WXSOCu7lXLl7rxYvc7iyIFjUACnwAUXoApuQQ3UAQaP4Bm8gjfryXqx3q2PeeuKlc0cgT+wPn8AOQWZ6g==</latexit>
!
à Its value is calculated by d j → bj Convert to
j=→m
decimal
10
Base 𝑏-system
Base b-system 1 1 1 0 1 . 1 1
Position 4 3 2 1 0 -1 -2
Power of 2s 2" 2# 2$ 2% 2& 2'% 2'$
Decimal 16 8 4 2 1 0.5 0.25
11
Base 𝑏-system
b. 456718
c. 14516
12
Convert number from decimal to base b-system
13
Convert number from decimal to base b-system
14
Convert number from decimal to base b-system
15
Convert number from decimal to base b-system
0.6875 x 2 = 1.375
0.375 x 2 = 0.75
0.75 x 2 = 1.5
0.5 x 2 = 1.0
16
Binary system
• Base b = 2
• Use two distinct values: 0, 1 à Binary digits (bits)
• A group of 𝒌 binary digits can be used to represent 2k
symbols
00...0002 Û 010
....
11...1112 Û 2n-110
E.g., Using 3 bits can represent 8 different values
000 001 010 011
100 101 110 111
17
Octal system
• Base b = 8
• Use eight distinct values: 0, 1, 2, 3, 4, 5, 6, 7
• Example: 235.648 à ?10
• Using 𝑘 digits can represent 8k different values
00...000 = 010
....
77...777 = (8n-1)10
• Each digit in octal system can be represented by a group
of 3-bits in binary system
18
Hexadecimal system
• Base b = 16
• Use sixteen distinct values:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
A B C D E F
19
Number representation in computers – units of information
20
Number representation in computers – units of information
21
Integer representation
• Unsigned Integers
• Signed Integers
22
Integer representation
• Unsigned Integers
• Same as we did so far
• Represented by a fixed number of bits (8, 16, 32 or 64)
àA finite set of number can be represented
• If an operation has a result outside this range à ‘overflow’
• Signed Integers
• The most significant bit is set to 0 and 1 for positive and
negative numbers
E.g., + 4210 = 001010102 = 32 + 8 + 2
– 4210 = 110101102
23
Integer representation
• Given n bits
• Unsigned integers: [0,…, 2n – 1]
• Signed integers: [-2n-1, 2n-1-1]
24
Two’s Complement
25
Two’s Complement
11010101
n→2
<latexit sha1_base64="q3b2IxPRDWQ5K53ghty5ZYh5I9Q=">AAACHHicbVDLSsNAFJ34rPUVdelmsAiCtCRVqhuh6MZlBfuApg2TybSddjIJMxOhhHyIG3/FjQtF3LgQ/BunaRfaemCYwzn3cu89XsSoVJb1bSwtr6yurec28ptb2zu75t5+Q4axwKSOQxaKlockYZSTuqKKkVYkCAo8Rpre6GbiNx+IkDTk92ockU6A+pz2KEZKS655VvTdhBfttNzNPngKHRkHbjKEV9BKJ2I5hb47hI6iAZGw3B26ZsEqWRngIrFnpABmqLnmp+OHOA4IV5ghKdu2FalOgoSimJE078SSRAiPUJ+0NeVID+ok2XEpPNaKD3uh0I8rmKm/OxIUSDkOPF0ZIDWQ895E/M9rx6p32Ukoj2JFOJ4O6sUMqhBOkoI+FQQrNtYEYUH1rhAPkEBY6TzzOgR7/uRF0iiX7EqpcndeqF7P4siBQ3AEToANLkAV3IIaqAMMHsEzeAVvxpPxYrwbH9PSJWPWcwD+wPj6AefRn24=</latexit>
!
à Its value is calculated by →dn→1 2n→1 + dj ↑ 2j
j=0
11010110(2) = →1 ↑ 27 + 1 ↑ 26 + 1 ↑ 24 + 1 ↑ 22 + 1 ↑ 21 = →128 + 64
<latexit sha1_base64="HCX7Y5a8NTYS4MCFVkCb9/Hlg9A=">AAACZHicbVHLagIxFM1MH1pr27HSVaGESsFSKpNBRjcFaTddWqgPUCuZGDWYeZBkCjL4k9112U2/oxl14aM3BM45997k5sSLOJPKtr8N8+Dw6DiTPcmd5s/OL6zCZVuGsSC0RUIeiq6HJeUsoC3FFKfdSFDse5x2vNlLmu98UiFZGLyreUQHPp4EbMwIVloaWglCtl7IHiZl534Bn+AjRLCvmE8ldD5q8GGTutu0uk2dbYrSw5BT16q7rEy7U+CkiaoDh1bJrtjLgPsArUEJrKM5tL76o5DEPg0U4VjKHrIjNUiwUIxwusj1Y0kjTGZ4QnsaBlgPMkiWJi3gnVZGcBwKvQMFl+pmR4J9Kee+pyt9rKZyN5eK/+V6sRrXBwkLoljRgKwuGsccqhCmjsMRE5QoPtcAE8H0rJBMscBE6X/JaRPQ7pP3QdupILfivlVLjee1HVlwDW5BGSBQAw3wCpqgBQj4MTKGZRSMXzNvFs2rValprHuKYCvMmz8W7Kg3</latexit>
1 ↑ 22 + 1 ↑ 21 = →128 + 64 + 16 + 4 + 2 = →42
27
Operations on Integers
28
Addition and Subtraction
• Binary addition:
0+0=0
0+1=1
1+0=1
1 + 1 = 0, and carry 1 to the next more significant bit
E.g: 00011010 + 00001100 = 00100110
1 1 carries
0 0 0 1 1 0 1 0 = 26 (base 10)
+ 0 0 0 0 1 1 0 0 = 12 (base 10)
0 0 1 0 0 1 1 0 = 38 (base 10)
29
Addition and Subtraction
• Binary subtraction :
0-0=0
0 - 1 = 1, borrow 1 from the next more significant bit
1-0=1
1-1=0
E.g.: 00100101 - 00010001 = 00100110
carries
0 0 1 0 0 1 0 1 = 37 (base 10)
+ 0 0 1
0 1 0 0 0 1 = 17 (base 10)
0 0 0 1 0 1 1 0 = 20 (base 10)
30
Addition and subtraction - Examples
• No overflow
skip
skip
31
Addition and subtraction - Examples
• Overflow
skip
skip
32
Multiplication and Division
• Binary multiplication
0x0=0
0x1=0
1x0=0
1 x 1 = 1, and no carry or borrow bits
• E.g.: 00101001 × 00000110 = 11110110
0 0 1 0 1 0 0 1 = 41(base 10)
× 0 0 0 0 0 1 1 0 = 6 (base 10)
0 0 0 0 0 0 0 0
0 0 1 0 1 0 0 1
0 0 1 0 1 0 0 1
0 0 1 1 1 1 0 1 1 0 = 246 (base 10)
33
Multiplication and Division
Dividend Divisor
Quotient
Partial
remainder
Remainder
34
Logical Operations on Binary Numbers
35
Logical Operations with One or Two Bits
36
Logical Operations with One or Two Integers
37
Symbol Representation
• Basic Principles
38
Basic Principles
39
Character Set
40
ASCII Code Table
41
Limitations of ASCII character set
42
ASCII Code Table
43
Unicode Character Set
44
Advantages of using Unicode
45
Audio presentation
47
Units of information
48
Units of information
49
THANK YOU !
50