0% found this document useful (0 votes)
0 views50 pages

IT1016 Lesson2

The document provides an introduction to fundamental concepts in Information Technology, covering topics such as communication applications, operating systems, programming, hardware, and data. It includes detailed units on data representation, number systems, and their operations in computers. Key concepts include decimal, binary, hexadecimal, and base-b systems, along with methods for converting between these systems.

Uploaded by

Thư Minh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views50 pages

IT1016 Lesson2

The document provides an introduction to fundamental concepts in Information Technology, covering topics such as communication applications, operating systems, programming, hardware, and data. It includes detailed units on data representation, number systems, and their operations in computers. Key concepts include decimal, binary, hexadecimal, and base-b systems, along with methods for converting between these systems.

Uploaded by

Thư Minh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Introduction to

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

• Unit 1. Basic Concepts

• Unit 2. Data Representation in a Computer

• Unit 3. Computer Systems

• Unit 4. Computer Network

• Unit 5. Operating Systems

4
Unit 2: Data representation in a computer

2.1. Number systems

2.2. Number representation in computers - Units of


information

2.3. Representation of integers

2.4. Operations on integers

2.5. Logical operations on binary numbers

2.6. Symbol representation

5
Number systems

• Decimal System

• Base-b System

• Conversion from Decimal to Base-b

• Binary System

• Hexadecimal System

• Octal System

6
Number systems

• A number system uses a finite number (𝑏) of symbols


(digits, letter,…) to represent all numeric values
• E.g., decimal system: 10 symbols

• 𝒃 is called the base (radix) of the number system


• E.g., decimal system: 𝑏 = 10

• Numeric values: Natural numbers, Integers, Rational


and Irrational numbers
• Numbers are written using positional notation
943 = 9 x 102 + 4 x 10 + 3

Only in base 10 (decimal)


7
Decimal system

• Use ten distinct values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

àBase 𝑏 = 𝟏𝟎

• Decimal separator indicates start of a fractional part

• Sign symbols + or − in front of numbers to indicate sign

8
Decimal system

• If 𝑖 is an integer written in decimal form with 𝒏 digits 𝑑!


i = dn→1 dn→2 . . . d1 d0
<latexit sha1_base64="GMqva+MNSTyN9Rh0hmprno7yUtQ=">AAACCHicbVDLSgMxFM34rPU16tKFwSK4scwUqW6EohuXFewD2mHIZDJtaCYZkoxQhi7d+CtuXCji1k9w59+YTmehrQcu93DOvST3BAmjSjvOt7W0vLK6tl7aKG9ube/s2nv7bSVSiUkLCyZkN0CKMMpJS1PNSDeRBMUBI51gdDP1Ow9EKir4vR4nxIvRgNOIYqSN5NtHFF7B0M/4mTvJW23SZ6HQyohu6Du+XXGqTg64SNyCVECBpm9/9UOB05hwjRlSquc6ifYyJDXFjEzK/VSRBOERGpCeoRzFRHlZfsgEnhglhJGQpriGufp7I0OxUuM4MJMx0kM1703F/7xeqqNLL6M8STXhePZQlDKoBZymAkMqCdZsbAjCkpq/QjxEEmFtsiubENz5kxdJu1Z169X63XmlcV3EUQKH4BicAhdcgAa4BU3QAhg8gmfwCt6sJ+vFerc+ZqNLVrFzAP7A+vwBhqqYag==</latexit>

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

• If 𝑖 is a rational/irrational number written in decimal form as


i = dn→1 dn→2 . . . d1 d0 .d→1 d→2 . . . d→m
<latexit sha1_base64="OYtcy8t5+z/T/6SI9Tju1LYewmI=">AAACInicbZBNS8MwGMdTX+d8q3r0EhyCl5V2yNSDMPTicYJ7ga2UNE23sDQtSSqM0s/ixa/ixYOingQ/jFm3w9x8IOTP7/88JM/fTxiVyra/jZXVtfWNzdJWeXtnd2/fPDhsyzgVmLRwzGLR9ZEkjHLSUlQx0k0EQZHPSMcf3U78ziMRksb8QY0T4kZowGlIMVIaeeYVhdcw8DJedfLiquV9FsRKaugEnm1pOLXmnawa5Z5ZsS27KLgsnJmogFk1PfOzH8Q4jQhXmCEpe46dKDdDQlHMSF7up5IkCI/QgPS05Cgi0s2KFXN4qkkAw1jowxUs6PxEhiIpx5GvOyOkhnLRm8D/vF6qwks3ozxJFeF4+lCYMqhiOMkLBlQQrNhYC4QF1X+FeIgEwkqnWtYhOIsrL4t2zXLqVv3+vNK4mcVRAsfgBJwBB1yABrgDTdACGDyBF/AG3o1n49X4ML6mrSvGbOYI/Cnj5xf9V6LG</latexit>

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

• Use 𝑏 distinct symbols


• If 𝑖 is an integer written in base-𝒃 form with 𝒏 digits 𝑑!
i = dn→1 dn→2 . . . d1 d0
<latexit sha1_base64="GMqva+MNSTyN9Rh0hmprno7yUtQ=">AAACCHicbVDLSgMxFM34rPU16tKFwSK4scwUqW6EohuXFewD2mHIZDJtaCYZkoxQhi7d+CtuXCji1k9w59+YTmehrQcu93DOvST3BAmjSjvOt7W0vLK6tl7aKG9ube/s2nv7bSVSiUkLCyZkN0CKMMpJS1PNSDeRBMUBI51gdDP1Ow9EKir4vR4nxIvRgNOIYqSN5NtHFF7B0M/4mTvJW23SZ6HQyohu6Du+XXGqTg64SNyCVECBpm9/9UOB05hwjRlSquc6ifYyJDXFjEzK/VSRBOERGpCeoRzFRHlZfsgEnhglhJGQpriGufp7I0OxUuM4MJMx0kM1703F/7xeqqNLL6M8STXhePZQlDKoBZymAkMqCdZsbAjCkpq/QjxEEmFtsiubENz5kxdJu1Z169X63XmlcV3EUQKH4BicAhdcgAa4BU3QAhg8gmfwCt6sJ+vFerc+ZqNLVrFzAP7A+vwBhqqYag==</latexit>

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

• If 𝑖 is a rational/irrational number written in base-𝒃 form as


i = dn→1 dn→2 . . . d1 d0 .d→1 d→2 . . . d→m
<latexit sha1_base64="OYtcy8t5+z/T/6SI9Tju1LYewmI=">AAACInicbZBNS8MwGMdTX+d8q3r0EhyCl5V2yNSDMPTicYJ7ga2UNE23sDQtSSqM0s/ixa/ixYOingQ/jFm3w9x8IOTP7/88JM/fTxiVyra/jZXVtfWNzdJWeXtnd2/fPDhsyzgVmLRwzGLR9ZEkjHLSUlQx0k0EQZHPSMcf3U78ziMRksb8QY0T4kZowGlIMVIaeeYVhdcw8DJedfLiquV9FsRKaugEnm1pOLXmnawa5Z5ZsS27KLgsnJmogFk1PfOzH8Q4jQhXmCEpe46dKDdDQlHMSF7up5IkCI/QgPS05Cgi0s2KFXN4qkkAw1jowxUs6PxEhiIpx5GvOyOkhnLRm8D/vF6qwks3ozxJFeF4+lCYMqhiOMkLBlQQrNhYC4QF1X+FeIgEwkqnWtYhOIsrL4t2zXLqVv3+vNK4mcVRAsfgBJwBB1yABrgDTdACGDyBF/AG3o1n49X4ML6mrSvGbOYI/Cnj5xf9V6LG</latexit>

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

For example: Convert 11101.112 to Decimal

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

11101.112 = 1 → 16 + 1 → 8 + 1 → 4 + 0 → 2 + 1 → 1 + 1 → 0.5 + 1 → 0.25 =


<latexit sha1_base64="avEFQPAFHGq7LJ9jKd5EA/wZV/I=">AAACYHicbVFJSwMxFM5MXWpd2upNL8EiCMKQDHbxIBS9eKxgVWiHIZOmGswsJBmlDP2T3jx48ZeYtiOOrQ8C35KXl3wJEsGVRujDsktr6xub5a3K9s7uXrVW379XcSop69NYxPIxIIoJHrG+5lqwx0QyEgaCPQQv1zP/4ZVJxePoTk8S5oXkKeJjTok2kl97wxgj7GDsu/ASYjjUPGQK4hY8+2WdIjk3BP0Qt+jgGckxcppFCzlu05zvXjjtpp9hNPVrDeSgecFVgHPQAHn1/Nr7cBTTNGSRpoIoNcAo0V5GpOZUsGllmCqWEPpCntjAwIiYsV42D2gKT4wyguNYmhVpOFeLHRkJlZqEgdkZEv2slr2Z+J83SPW442U8SlLNIroYNE4F1DGcpQ1HXDKqxcQAQiU3d4X0mUhCtfmTigkBLz95Fdy7Dm45rdvzRvcqj6MMjsAxOAUYtEEX3IAe6AMKPq2StWPtWl922a7a9cVW28p7DsCfsg+/AYZ8qac=</latexit>

→ 0.5 + 1 → 0.25 = 29.7510

11
Base 𝑏-system

Excercise: Convert following numbers to decimal


a. 110010.10012

b. 456718

c. 14516

12
Convert number from decimal to base b-system

• Convert integers from decimal to base b-system


Remainder method:
• Let value = (dn-1 dn-2 … d2 d1 d0)10.
• Step 1: Divide value by b to get quotient r0 and remainder b0
• Step 2: Divide r0 by b to get quotient r1 and remainder is b1
• Step 3: Divide r1 by b to get quotient r2 and remainder is b2
• ….

• Continue divide quotients by b the until the result is equal to


0 and get final remainder bm-1.
• The result is bm-1 bm-2 … b2 b1 b0

13
Convert number from decimal to base b-system

• Convert integers from decimal to base b-system


Example: convert to binary system (b = 2)

Excercise: 6310, 2010, 8110, 12610 à ?2

14
Convert number from decimal to base b-system

• Convert Decimal Fractions to base b-system


• Let value = (0.d-1 d-2 … d-m)10.
• Step 1: Multiply value by b to get results in form x1.y1
• Step 2: If y1 is not 0, multiply 0.y1 by b to get results x2.y2
• Step 3: If y2 is not 0, multiply 0.y2 by b to get results x3.y3
• ….

• Continue multiply until the result in form xn.0


• The result is 0.x1 x2 … xn

15
Convert number from decimal to base b-system

• Convert Decimal Fractions to base b-system


Example: Convert 0.687510 à binary system (b = 2)

0.6875 x 2 = 1.375
0.375 x 2 = 0.75
0.75 x 2 = 1.5
0.5 x 2 = 1.0

Results: 0.687510 = 0.10112

Exercise: Convert 0.62510, 0.562510, 5.2510 à binary system


Convert 0.110, 0.1110à binary system

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

• Example: 23D.A16 à ?10


• Each digit in hexa system can be represented by a group of
4-bits in binary system

19
Number representation in computers – units of information

• Real world produces two kinds of information:


• Analog: continuous and infinite
• Digital: discrete and finite

• Computers are finite


• All data in a computer system is represented by
binary digits (bits)
• Data can be numbers, symbols, images, sounds . . .

20
Number representation in computers – units of information

• Various ways to encode different types of data:


• Numbers are converted to their binary representations
following some standards
• Symbols are assigned to a bit pattern
• Other data must be digitalized

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]

• How to represent negative numbers?


à Two’s Complement

24
Two’s Complement

• Representation for signed binary numbers


• Leading bit is a sign bit
• Binary number with leading 0 is positive
• Binary number with leading 1 is negative
• Magnitude of positive numbers is just the binary
representation
• Magnitude of negative numbers is found by
• Complement the bits: replace all the 1's with 0's, and all the
0's with 1’s – one’s complement
• Add one to the complemented number
• The carry in the most significant bit position is thrown
away when performing arithmetic

25
Two’s Complement

• E.g.: Represent -42 using eight bits

• Step 1: Convert 42 to binary system using eight bits


42 = 001010102

• Step 2: Calculate one’s complement (bit inversion)


42 = 001010102

11010101

• Step 3: Add 1 to get two’s complement


11010101
+ 1 à Representation of -42 in computers
11010110
26
Value of binary-form signed integers

• A signed binary integer number


i = dn→1 dn→2 . . . d1 d0
<latexit sha1_base64="GMqva+MNSTyN9Rh0hmprno7yUtQ=">AAACCHicbVDLSgMxFM34rPU16tKFwSK4scwUqW6EohuXFewD2mHIZDJtaCYZkoxQhi7d+CtuXCji1k9w59+YTmehrQcu93DOvST3BAmjSjvOt7W0vLK6tl7aKG9ube/s2nv7bSVSiUkLCyZkN0CKMMpJS1PNSDeRBMUBI51gdDP1Ow9EKir4vR4nxIvRgNOIYqSN5NtHFF7B0M/4mTvJW23SZ6HQyohu6Du+XXGqTg64SNyCVECBpm9/9UOB05hwjRlSquc6ifYyJDXFjEzK/VSRBOERGpCeoRzFRHlZfsgEnhglhJGQpriGufp7I0OxUuM4MJMx0kM1703F/7xeqqNLL6M8STXhePZQlDKoBZymAkMqCdZsbAjCkpq/QjxEEmFtsiubENz5kxdJu1Z169X63XmlcV3EUQKH4BicAhdcgAa4BU3QAhg8gmfwCt6sJ+vFerc+ZqNLVrFzAP7A+vwBhqqYag==</latexit>

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

• E.g.: Value of signed binary integer number 11010110

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

• Addition and Subtraction

• Multiplication and Division

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

• Binary division: follows the same rules as in decimal division

Dividend Divisor

Quotient
Partial
remainder

Remainder

34
Logical Operations on Binary Numbers

• Logical Operations with One or Two Bits


• AND, OR, XOR, NOT

• Logical Operations with One or Two Integers


• AND, OR, XOR, NOT

35
Logical Operations with One or Two Bits

• AND: Compares 2 bits and if they are both 1, then the


result is 1, otherwise, the result is 0
• OR: Compares 2 bits and if either or both bits are 1,
then the result is 1, otherwise, the result is 0.
• XOR: (Exclusive OR) : Compares 2 bits and if exactly
one of them is 1 then the result is 1 otherwise (if the
bits are the same), the result is 0.
• NOT: Changes the value of a single bit. If it is a 1, the
result is 0; if it is a 0, the result is 1.
Truth Table of Logical Operations

36
Logical Operations with One or Two Integers

• AND: perform the logical AND operation on each pair


of corresponding bits in right alignment

• OR: perform the logical OR operation on each pair of


corresponding bits in right alignment

• XOR: performs the logical XOR operation on each pair


of corresponding bits

• NOT: perform NOT operation on each bit

37
Symbol Representation

• Basic Principles

• ASCII Code Table

• Unicode Code Table

38
Basic Principles

• Text documents can be decomposed into individual


characters à handle character data
• Character data isn't just alphabetic characters, but also
numeric characters, punctuation, spaces, etc.
• They need to be represented in binary
• There aren't mathematical properties for character
data, so assigning binary codes for characters is
somewhat arbitrary

39
Character Set

• A list of characters and the codes used to represent


each one.

• By using a particular character set, computer


manufacturers have made the processing of data
easier.

• Two popular character sets: ASCII & Unicode

40
ASCII Code Table

• ASCII -- American Standard Code for Information


Interchange - permitted machines from different
manufacturers to exchange data.
• The ASCII standard was developed in 1963

• ASCII standard originally used 7 bits to represent


characters -> consists of 128 binary values (0 to 127),
each associated with a character or command
• The extended ASCII character set used 8 bits to
represent characters. It also consists 128 characters
representing additional special, mathematical, graphic
and foreign characters.

41
Limitations of ASCII character set

42
ASCII Code Table

• String data types allocated one byte per character


• The extended version of ASCII which have 256
characters is enough for English but not enough for
international use
• Logographic languages such as Chinese, Japanese,
and Korean need far more than 256 characters for
reasonable representation.
• Vietnamese need 61 characters for representation.

43
Unicode Character Set

• Provides a unique number for every character

• Uses 16 bits or more per character

• Has been adopted by such industry leaders as HP,


IBM, Microsoft, Oracle, Sun, and many others.

• Is supported in many operating systems, all modern


browsers, and many other products.

44
Advantages of using Unicode

• Significant cost savings

• Enables software products to be targeted across


multiple platforms, languages and countries without re-
engineering.

• Allows data to be transported through many different


systems without corruption.

45
Audio presentation

• Audio ~ sound wave: analog signals

Digitalized by sampling Reproduce the sound

• Sampling: periodically measure the voltage of the


signal and record appropriate value
• Audio format : WAV,AU, AIFF, VQF, MP3
46
Image presentation

• Image: a collection of individual dots called pixel


• Each pixel is composed of a single color
• Color: expressed as an RGB (red – green – blue) value
• Color depth: Amount of data that used to represent a color
• HiColor: 16 bit color depth
• TrueColor: 24bit color depth
• Resolution: number of pixels used
to represent a picture
• 640 x 480, 1270 x 480,
1920 x 1024

47
Units of information

• The smallest unit of information a computer can use


is bit (Binary Digit)
• The difference between two states (high current and
low current) is represented as one of two numbers
(1 or 0).
• A collection of 8 bits are put together to form a byte
• Binary prefixes can be used to quantify computer
memory sizes
• Each successive prefix is multiplied by 1024 (210)
rather than the 1000 (103)

48
Units of information

49
THANK YOU !

50

You might also like