0% found this document useful (0 votes)
19 views

Lecture#5 Jan2023

Uploaded by

eshaarshad456
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Lecture#5 Jan2023

Uploaded by

eshaarshad456
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

COMP1111

Introduction to Information Technology

Lecture # 05 Number Systems

Instructor: Dr. Aftab Akram (PhD CS)


Assistant Professor
Computers and Number Systems
• Computer is a binary machine.
• Every thing inside Computer is represented by 0 or
1.
• i.e., Binary Number System (Base-2) is used in
Computers.
• In routine life we use Decimal Number System
(Base-10), i.e.,10 digits from 0 to 9.
• However, Otcal (Base-8) and Hexdecimal (Base-16)
are also used in Computers, e.g., representing
Computer’s memory
Conversion between Systems
• First, we need to understand why there are Binary
Computers?
• Why Decimal Computers weren’t built?
• Binary Number System has two digits, i.e., 0 & 1.
• Plenty of ways to represent Binary digits:
• Using a transistor, ON & OFF
• Using a capacitor, CHARGED & DISCHARGED
• Using magnetic poles orientation: N-N or S-S & N-S
• Difficult to build a device that can represent 10
distinct levels with same accuracy.
Conversion between Systems
• However, building Binary Computers is not easy.
• Since, all real world information need to be
converted into Binary, and then back again.
• This makes building and operating Binary
Computers quite difficult.
• However, common user does not need to do this.
• The Computer System includes a mechanism which
does this automatically.
• Each time we use Computer this process is
automatically happening.
Conversion between Systems
Step 1.
The user presses Step 2.
the capital letter An electronic signal for
D (shift+D key) the capital letter D is sent
on the keyboard. to the system unit.

Step 4. Step 3.
After processing, the binary The signal for the capital
code for the capital letter D letter D is converted to its
is converted to an image, and ASCII binary code
displayed on the output (01000100) and is stored in
device. memory for processing.
Understanding Number Systems
• A number system is a system representing
numbers.
• It is also called the system of numeration and it
defines a set of values to represent a quantity.
• The value of any digit in a number can be
determined by a digit, its position in the number,
and the base of the number system.
• The numbers are represented in a unique manner
and allow us to operate arithmetic operations like
addition, subtraction, and division.
Types of Number Systems
• There are different types of number systems in
which the four main types are as follows.
• Binary number system (Base - 2)
• Octal number system (Base - 8)
• Decimal number system (Base - 10)
• Hexadecimal number system (Base - 16)
Types of Number Systems
Conversion between Systems
• A number can be converted from one number
system to another number system using number
system formulas.
• Typically, we need to learn how to convert numbers
between Binary and Decimal Number Systems
• Since, this type of conversion will be used mostly in
Computer operations.
Conversion of Binary to Decimal
Number System
• To convert a number from the binary to the decimal
system, we use the following steps:
• Step 1: Multiply each digit of the given number, starting
from the rightmost digit, with the exponents of the base
(e.g., base of Binary Number System is 2).
• Step 2: The exponents should start with 0 and increase
by 1 every time we move from right to left.
• Step 3: Simplify each of the above products and add
them.
Conversion of Binary to Decimal
Number System
• Example: Convert 1001112 into the decimal system.
• Solution:
• Step 1: Identify the base of the given number. Here, the
base of 1001112 is 2.
• Step 2: Multiply each digit of the given number, starting
from the rightmost digit, with the exponents of the
base.
Conversion of Binary to Decimal
Number System
Conversion of Binary to Decimal
Number System
• Step 3: We just simplify each of the above products
and add them.
Conversion of Binary to Decimal
Number System
100111 = (1 × 25) + (0 × 24) + (0 × 23) + (1 × 22) + (1 × 21) + (1 × 20)
= (1 × 32) + (0 × 16) + (0 × 8) + (1 × 4) + (1 × 2) + (1 × 1)
= 32 + 0 + 0 + 4 + 2 + 1
= 39
Thus, 1001112 = 3910.
Conversion of Decimal Number System to
Binary / Octal / Hexadecimal Number System
• Example: Convert 432010 into the octal system.
• Solution:
• Step 1: Identify the base of the required number. Since
we have to convert the given number into the octal
system, the base of the required number is 8.
• Step 2: Divide the given number by the base of the
required number and note down the quotient and the
remainder in the quotient-remainder form.
• Repeat this process (dividing the quotient again by the
base) until we get the quotient less than the base.
Conversion of Decimal Number System to
Binary / Octal / Hexadecimal Number System
Conversion of Decimal Number System to Binary /
Octal / Hexadecimal Number System

• Step 3: The given number in the octal number


system is obtained just by reading all the
remainders and the last quotient from bottom to
top.

• Therefore, 432010 = 103408


Conversion from Binary Number System to
Octal/ Hexadecimal Number System
• To convert a number from Binary to Octal or
Hexadecimal Number System, we can use a long
method and a direct method.
• In long method, we use technique used to convert from
Binary to Decimal, then Decimal to Octal or
Hexadeicmal.
• A short or direct method is useful when you have some
practice to convert from Binary to Decimal. We make
groups of 3 or 4 bits, and then convert it to decimal
number system.
Conversion from Binary Number System to
Octal/ Hexadecimal Number System (Long
Method)
• Example: Convert 10101111002 to the hexadecimal
system.
• Solution:
• Step 1: Convert this number to the decimal number
system as explained in the above process.
Conversion from Binary Number System to
Octal/ Hexadecimal Number System (Long
Method)

• Thus, 10101111002 = 70010 → (1)


Conversion from Binary Number System to
Octal/ Hexadecimal Number System (Long
Method)
• Step 2: Convert the above number (which is in the
decimal system), into the required number system
(hexadecimal).

• Thus, 70010 = 2BC16 → (2)


• From the equations (1) and (2), 10101111002 =
2BC16
Conversion from Binary Number System to
Octal/ Hexadecimal Number System (Direct
Method)
• In Direct method, we make groups of 3 or 4 bits
depending on the conversion to Octal or
Hexadecimal Number System.
• Example: Convert 10101111002 to the Octal
system.
• Step 1: Make groups of 3 bits starting from right
most bit.
001 010 111 100
(You may enter extra zeros on the left if less than 3
digits)
Conversion from Binary Number System to
Octal/ Hexadecimal Number System (Direct
Method)
• Step 2: Convert each group to equivalent decimal
numbers.

001 010 111 100

1 2 7 4

• Step 3: Combine these numbers get desired octal


number 12748
Conversion from Binary Number System to
Octal/ Hexadecimal Number System (Direct
Method)
• Exercise: Convert 10101111002 to Hexadecimal
using direct method.
Encoding Techniques
• The process of conversion of data from one form to
another form is known as Encoding.
• It is used to transform the data so that data can be
supported and used by different systems.
• Encoding is used in mainly two fields:
• Encoding in Electronics: In electronics, encoding refers
to converting analog signals to digital signals, and back
again.
• Encoding in Computing: In computing, encoding is a
process of converting data to an equivalent binary form.
Type of Encoding Technique in
Computing

Types of Encoding
Techniques

Image, Audio, Video


Character Encoding
Encoding
Character Encoding
• Character encoding encodes characters into bytes.
• It informs the computers how to interpret the zero and
ones into real characters, numbers, and symbols.
• The computer understands only binary data; hence it is
required to convert these characters into numeric codes.
• To achieve this, each character is converted into binary
code.
• It can be done by pairing numbers with characters.
• Character encoding makes sure that each character has
a proper representation in computer or binary format.
Types of Character Encoding
Techniques
• HTML Encoding
• HTML encoding is used to display an HTML page in a
proper format.
• With encoding, a web browser gets to know that which
character set to be used.
• URL Encoding
• URL (Uniform resource locator) Encoding is used
to convert characters in such a format that they can be
transmitted over the internet.
• It is also known as percent-encoding.
• Percent-encoding is a mechanism to encode 8-bit
characters that have specific meaning in the context of
URLs.
Types of Character Encoding
Techniques
• ASCII Encoding
• American Standard Code for Information Interchange
• ASCII is a type of character-encoding.
• It was the first character encoding standard released in the year
1963.
• ASCII code is used to represent English characters as
numbers, where each letter is assigned with a number
from 0 to 127.
• Most modern character-encoding schemes are based on
ASCII, though they support many additional characters.
• It is a single byte encoding only using the bottom 7 bits.
• In an ASCII file, each alphabetic, numeric, or special
character is represented with a 7-bit binary number.
• Each character of the keyboard has an equivalent ASCII
value.
Types of Character Encoding
Techniques
• The first thirty-two codes (numbers 0-31 decimal) in ASCII
are reserved for control characters: codes that may not
themselves represent information, but that are used to
control devices (such as printers) that make use of ASCII.
• For example, character 10 represents the "line feed"
function (which causes a printer to advance its paper), and
character 27 represents the "escape" key found on the top
left of common keyboards.
• Code 32 is the "space" character, denoting the space
between words, which is produced by the large space bar of
a keyboard.
• Codes 33 to 127 are called the printable characters, which
represent letters, digits, punctuation marks, and a few
miscellaneous symbols.
Types of Character Encoding
Techniques
• Unicode Encoding
• Unicode is an encoding standard for a universal
character set.
• It allows encoding, represent, and handle the text
represented in most of the languages or writing systems
that are available worldwide.
• It provides a code point or number for each character in
every supported language.
• It can represent approximately all the possible
characters possible in all the languages.
• A UNICODE standard can use 8, 16, or 32 bits to
represent the characters.
Types of Character Encoding
Techniques
• The Unicode standard defines Unicode Transformation
Format (UTF) to encode the code points.
• UNICODE Encoding standard has the following UTF
schemes:
• UTF-8 Encoding: Actually the ASCII encoding adaptation.
• UTF-8 is capable of encoding all 1,112,064 valid character code
points.
• UTF-16 Encoding: UTF16 Encoding represents a character's
code points using one of two 16-bits integers.
• UTF-32 Encoding: UTF32 Encoding represents each code
point as 32-bit integers.
Types of Character Encoding
Techniques
• Base64 Encoding
• Base64 Encoding is used to encode binary data into
equivalent ASCII Characters.
• Common to all binary-to-text encoding schemes, Base64
is designed to carry data stored in binary formats across
channels that only reliably support text content.
• The Base64 encoding is used in the Mail system as mail
systems such as SMTP can't work with binary data
because they accept ASCII textual data only.
• Base64 is also widely used for sending email
attachments.
Image and Audio & Video
Encoding
• Image and audio & video encoding are performed to
save storage space.
• A media file such as image, audio, and video are
encoded to save them in a more efficient and
compressed format.
• These encoded files contain the same content with
usually similar quality, but in compressed size, so that
they can be saved within less space, can be transferred
easily via mail, or can be downloaded on the system.
• For example, a . WAV audio file is converted into .MP3
file to reduce the size by 1/10th to its original size.

You might also like