Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views19 pages

Unit2 (Data Representation in Computer)

The document provides an introduction to data representation in computers, emphasizing the importance of the binary system for processing various types of data, including numbers, letters, and multimedia. It explains key concepts such as bits, bytes, and different number systems (decimal, binary, octal, hexadecimal), along with methods for converting between these systems. Additionally, it covers how computers interpret keyboard input and convert images and audio into binary format.

Uploaded by

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

Unit2 (Data Representation in Computer)

The document provides an introduction to data representation in computers, emphasizing the importance of the binary system for processing various types of data, including numbers, letters, and multimedia. It explains key concepts such as bits, bytes, and different number systems (decimal, binary, octal, hexadecimal), along with methods for converting between these systems. Additionally, it covers how computers interpret keyboard input and convert images and audio into binary format.

Uploaded by

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

Course: Introduction To Programming With

C Language

Lecturer : Shimirwa Aline Valerie


Email: [email protected]
Tel: 0784931189
Unit 2: Data Representation In Reason for using binary system in computers
Computers It has proved difficult to develop devices that can
 Data and instructions cannot be entered and processed understand natural language directly due to the complexity
of natural languages. However, it is easier to construct
directly into computers using human language. Any electric circuits based on the binary or ON and OFF logic.
type of data be it numbers, letters, special symbols, All forms of data can be represented in binary system
sound or pictures must first be converted into format.
machine-readable form.
Bits, bytes, nibble and word
 Electronic components, such as microprocessor, are
The terms bits, bytes, nibble and word are used widely in
made up of millions of electronic circuits. The reference to computer memory and data size.
availability of high voltage(on) in these circuits is  Bits: can be defined as the basic unit of data or
interpreted as ‘1’ while a low voltage (off) is information in digital computers. Bit can be 0, or 1.
interpreted as ‘0’.This concept can be compared to
 Byte: a group of 8 bits which is used to represent a
switching on and off an electric circuit. The sequence
of ON’S and OFF’S forms the electrical signals that character. A byte is considered as the basic unit of
measuring memory size in computer.
the computer can understand. This forms a basis for  A nibble: is half a byte, which is usually a grouping
describing data representation in digital computers of 4 bits.
using the binary number system.  Word: two or more bits make a word. The
term word length is used as the measure of the
number of bits in each word. For example, a word
can have a length of 16 bits, 32 bits, 64 bits etc.
Types Of Data
Representation
 Computers not only process numbers, letters and special
symbols but also complex types of data such as sound
and pictures.
How to represent numbers in a computer?
Numbers can be represented using number systems
 A number system is a set of symbols used to represent
numbers in a computer. A number system has a unique
base, which depends upon the number of symbols. The
number of symbols used in a number system is called the
base or radix of a number system. Below are some of the
number systems computers can supports:
 Decimal Number System
 Binary Number System
 Octal Number System
 Hexadecimal Number System
Types Of Data Representation
Cont.…
Binary Number System
Decimal Number System
This system uses two digits namely, 1 and 0 to
 The term decimal is derived from a Latin prefix
represent numbers.
deci, which means ten. Decimal number system has
ten digits ranging from 0-9. Because this system Unlike in decimal numbers where the place
has ten digits; it is also called a base ten number value goes up in factors of ten, in binary system,
system or denary number system. the place values increase by the factor of 2.binary
 A decimal number should always be written with a numbers are written as X2.
subscript 10 e.g. 510 Consider a binary number such as 10112.The
 But since this is the most widely used number right most digit has a place value of 1×20 while
system in the world, the subscript is usually the left most has a place value of 1×23.
understood and ignored in written work.
However ,when many number systems are
considered together, the subscript must always be
put so as to differentiate the number systems.
 The place values goes up in factors of ten. consider
a decimal number such as 748510.The right most
digit has a place value of 5×100 while the left most
3
Types Of Data Representation
Cont.…
Hexadecimal Number System
Octal Number System
This is a base 16 number system that consists of
 The octal number system has only eight (8) digits
sixteen digits ranging from 0-9 and letters A-F where A
from 0 to 7.
is equivalent to 10,B to 11 up to F which is equivalent
 The base of the octal number system is 8, because it to 15 in base ten system. The place value of
has only 8 digits. E.g., X8 hexadecimal numbers goes up in factors of sixteen.
A hexadecimal number can be denoted using 16 as a
subscript to the right of the number .For example, 94B
can be written as 94B16
Conversion Of Numbers From
One Number System To Another

 To convert numbers from one system to another. the EXAMPLE


following conversions will be considered: Conversion from Binary to Decimal. Example.
 Converting between binary and decimal numbers. Convert 1101101 2 to Decimal. Below is the answer.
 Converting octal numbers to decimal and binary
form.
 Converting hexadecimal numbers to decimal and
binary form.
Converting binary numbers to decimal numbers
 To convert a binary number to a decimal number, we
proceed as follows:
 First, write the place values starting from the right hand
side.
 Write each digit under its place value.
 Multiply each digit by its corresponding place value.
 Add up the products. The answer will be the decimal
number in base ten.
Conversion Of Numbers From
One Number System To Another

Converting decimal numbers to binary


numbers
 Step 1 − Divide the decimal number to be converted by
2.
 Step 2 − repeat step1 until the quotient is 0.
 Step 3 −then write the reminder from right to left or
from bottom to top.

Example: Convert 109 10 to binary

Answer is on the right side


Conversion Of Numbers From
One Number System To Another

Conversion form Decimal to Octal Conversion form octal to Decimal


 First, write the place values starting from
 Step 1 − Divide the decimal number to be converted by the right hand side.
8.  Write each digit under its place value.
 Step 2 − repeat step1 until the quotient is 0.  Multiply each digit by its corresponding
 Step 3 −then write the reminder from right to left or place value.
from bottom to top.  Add up the products. The answer will be
the decimal number in base ten.
Example: Convert 155 8 to decimal
Example: Convert 109 10 to octal
Conversion Of Numbers From
One Number System To Another

Conversion form Octal to Binary


Conversion form Octal to Binary
In order to use the conversion table we group
 A simple relationship exists between octal and the binary digits into threes working from
binary, because eight is the cube of two. To do right to left, adding extra zeros at the left end
conversions it is merely necessary to remember if necessary.
binary equivalents for the eight octal symbols. The
Example: Convert 1110111000010 2 to octal.
conversion table is shown below:

Example: Convert 155 8 to binary


Conversion Of Numbers From
One Number System To Another

Conversion form Decimal to Hexadecimal Conversion form Hexadecimal to Decimal


 First, write the place values starting from
 Step 1 − Divide the decimal number to be converted by the right hand side.
16.  Write each digit under its place value.
 Step 2 − repeat step1 until the quotient is 0.  Multiply each digit by its corresponding
 Step 3 −then write the reminder from right to left or place value.
from bottom to top.  Add up the products. The answer will be
the decimal number in base ten.
Example: Convert 6D 16 to decimal
Example: Convert 109 10 to Hexadecimal
Conversion Of Numbers From
One Number System To Another

Conversion between Hex, Octal and Binary. Example1 : Convert 6D 16 to Binary


 Conversion between hex, octal and binary is done in A conversion between hex and octal is most easily
made via binary.
much the same way as the octal/binary conversions.
A conversion table is shown in figure below: Step 1. (Hex to Binary)

Stage 2. (Binary to Octal)

Example 2: Convert 1110111000010 2 to


Hex.
Data Representation Of
Characters
 Computers represent characters using character Since there are exactly 128 unique combinations
encoding schemes, which are sets of rules that assign of 7 bits, this 7-bit code can represent only128
numerical values to each character. These numerical characters. Another version is ASCII-8, also
values are then stored and manipulated by the computer called extended ASCII, which uses 8 bits for each
as binary data. character, can represent 256 different characters.
 The most widely used character encoding scheme is The ASCII standard is not "installed" on a
Unicode, which assigns a unique numerical value to computer as it is a set of rules and codes for
every character in the world. representing characters as numbers. However, the
 Another widely used encoding scheme is ASCII ASCII codes are often embedded in computer
(American Standard Code for Information Interchange). systems as part of the operating system or
It uses 7 bits to represent each character in computer software applications.
memory. In ASCII code a unique integer number is
assigned to each character and this number is converted
into binary for storing in memory. For example, the
ASCII code of A is 65, its binary equivalent in 7-bit is
1000001.
Assignement1
1. Convert 1011001012 to base Ten

2. Convert 35710 to the corresponding binary number

3. Convert 35710to the corresponding base-eight number

4. Convert 5458 to the corresponding decimal number

5. Convert 6F16 to Binary and Octal

6. Convert 16516 to the corresponding decimal number

7. Convert 6393310 to the corresponding hexadecimal number

8. Convert F9BD16 to decimal number

9. Convert 11101110000102 to octal


Assignment 1
10. How computer understand what you type on a keyboard?
11. Why computers understands only binary numbers?
12. How images, audios and videos are converted into binary format?

13. Define a program

14. What are Basic Principles of Programming?

15. Discuss portability and maintainability in program design.

16. What different stages which are involved in program development?


How computer understand These binary codes are then stored in a buffer,
what you type on a which is a temporary storage area in the
keyboard? computer's memory. As you continue typing, the
buffer fills up with the binary codes representing
 When you type on a keyboard, the keys each character, and the computer's processor
you press send electrical signals to the retrieves them from the buffer and sends them to
computer's processor. These signals are the appropriate application.
then processed by the computer's Once the application receives the binary codes,
input/output (I/O) system, which converts it uses a character encoding system to convert
the signals into digital information that the them into the actual characters that you typed.
computer can understand. The most common character encoding system
 The I/O system uses a device driver, which used today is Unicode, which can represent
almost every character from every language in
is a software program that controls the
the world.
keyboard and communicates with the
computer's operating system. The device
driver translates the electrical signals from
the keyboard into a series of binary codes
that represent the characters you are
typing.
Binary numbers are well-suited for use in digital
Why computers electronics because they are simple and efficient
understands only binary? to work with. They can be represented using just
two digits, 0 and 1, and can be combined to
represent larger numbers and other types of data.
 Computers understand only binary numbers
This simplicity and efficiency make binary
because they are made up of electronic numbers an ideal choice for storing and
circuits that can be in one of two states: on or processing information in electronic devices like
off, represented by the binary digits 1 and 0,
computers.
respectively. These circuits are commonly
referred to as switches, and they are the basic While humans typically use decimal (base 10)
building blocks of all digital electronics. numbers for counting and calculations, computers
 When you type on a keyboard, for example, use binary (base 2) numbers as their fundamental
the keystrokes are converted into electrical language for processing information. However, it
signals that are transmitted through wires and is possible to convert between different number
processed by the computer's hardware. The bases using mathematical algorithms, which
computer interprets these signals as patterns allows humans and computers to communicate
of on and off states in the electronic circuits, with each other using a variety of number
which are represented as binary digits. systems.
how does computer convert 3. Compression: In some cases, the image data is then
image into binary format? compressed to reduce the file size. There are many different
 Computers convert images into binary format compression algorithms that can be used, each with its own
strengths and weaknesses.
through a process called digital image encoding.
This process involves converting the visual 4. Encoding: Finally, the quantized and compressed image
information contained in the image into digital data data is encoded using binary code, typically represented using
that can be represented using binary code. a sequence of 0s and 1s. For example, each pixel's color value
might be represented using 24 bits of binary code (8 bits for
 Here are the general steps involved in converting an each of the red, green, and blue channels), resulting in a total
image into binary format: of 24 binary digits for each pixel.
1.Sampling: The image is divided into a grid of
tiny squares called pixels. Each pixel contains a Once the image has been encoded in binary format, it
color value that represents the color of that point in can be stored in a digital image file format, such as
the image. JPEG, PNG, or BMP. When the image is displayed on a
2.Quantization: The color values for each pixel are computer screen or printed out, the computer reads the
then quantized, or mapped, to a discrete set of binary data and converts it back into a visual
values. For example, in the RGB color model, each representation of the image.
color channel is typically represented using 8 bits,
which allows for 256 possible values for each
channel. This means that the color values for each
pixel can be represented using a total of 24 bits (3
bytes) of data.
how does computer convert 3. Compression: In some cases, the audio data is then
audio into binary format? compressed to reduce the file size. There are many different
compression algorithms that can be used, each with its own
 Computers convert audio into binary format
strengths and weaknesses.
through a process called analog-to-digital
conversion (ADC). This process involves 4. Encoding: Finally, the quantized and compressed audio data
is encoded using binary code, typically represented using a
measuring the sound waves of the audio signal at
sequence of 0s and 1s. For example, each sample might be
regular intervals and converting those represented using 16 bits of binary code, resulting in a total of
measurements into digital data that can be 16 binary digits for each sample.
represented using binary code.
 Here are the general steps involved in converting
Once the audio has been encoded in binary format, it
audio into binary format: can be stored in a digital audio file format, such as MP3
1. Sampling: The audio signal is divided into small
or WAV. When the audio is played back on a computer or
sections called samples, typically taken at a rate of other device, the digital data is converted back into an
44,100 samples per second for CD-quality audio. Each analog signal that can be heard through speakers or
sample represents the amplitude of the sound wave at headphones.
a particular moment in time.
2. Quantization: The amplitude of each sample is then
quantized, or mapped, to a discrete set of values. This
allows the audio data to be represented using binary
code. For example, in the commonly used Pulse Code
Modulation (PCM) method, each sample is quantized
to a certain number of bits, such as 16 bits per sample.
How Does Computer
Convert Video Into Binary 3. Compression: In some cases, the video data is then
Format? compressed to reduce the file size. There are many different
compression algorithms that can be used, each with its own
 Computers convert video into binary format strengths and weaknesses.
through a process called digital video encoding.
4. Encoding: Finally, the quantized and compressed video
This process involves converting the visual data is encoded using binary code, typically represented using
information contained in the video into digital a sequence of 0s and 1s. For example, each pixel's color value
data that can be represented using binary code. might be represented using 24 bits of binary code (8 bits for
 Here are the general steps involved in each of the YUV channels), resulting in a total of 24 binary
digits for each pixel.
converting video into binary format:
1. Sampling: The video is divided into a series of Once the video has been encoded in binary format, it can
still images called frames. Each frame contains be stored in a digital video file format, such as MP4 or
a snapshot of the visual information at a AVI. When the video is played back on a computer or
particular moment in time.
other device, the digital data is converted back into a
2. Quantization: The color values for each pixel visual representation of the video, typically by displaying
in each frame are then quantized, or mapped, each frame in sequence at a high rate of speed.
to a discrete set of values. This allows the
visual information to be represented using
binary code. For example, in the commonly
used YUV color model, each color channel is
typically represented using 8 bits, which
allows for 256 possible values for each
channel.

You might also like