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

CS 211 - Part I

The document provides an overview of number systems and data representation in digital computers, focusing on binary, octal, and hexadecimal systems. It explains how data is stored in binary format, the structure of computer memory, and the conversion methods between different bases. Additionally, it includes examples of converting decimal numbers to binary, octal, and hexadecimal, as well as the reverse process.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

CS 211 - Part I

The document provides an overview of number systems and data representation in digital computers, focusing on binary, octal, and hexadecimal systems. It explains how data is stored in binary format, the structure of computer memory, and the conversion methods between different bases. Additionally, it includes examples of converting decimal numbers to binary, octal, and hexadecimal, as well as the reverse process.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

ATBU Bauchi, DMS_ CS211 Note.

2017/2018

PART 1: NUMBER SYSTEM & DATA REPRESENTATION

Data represents facts about entities. It can also be defined as unprocessed information.
Example of data is: age, registration number, tests score of students. Another example is
Records of daily sales of a supermarket.

Data can be in textual format. Numbers or digits (eg 1, 6, 25 etc), alphabets (eg Musa, Ali,
Joy etc), alpanumeric (eg, Alice&23;Bob_1980). Data can be in non-textual format such as
Audio/Sound, pictures and video.

Digital Computers use representation based on a binary system. The binary number system
has TWO digits 0 and 1. Any data whether textual or non-textual, is stored in computer
memory as a sequence of binary digits (bit).

The main memory of computer (RAM) is logically structured as a linear array of cells, each
of which stores string of binary digits (0s and 1s) representing data or instruction. The
memory cells are organized into group of bits often called word of fixed size. For easy
access, each of the memory cells is associated with a unique address. The addresses are
consecutive numbers starting from 0 specifying successive memory locations. The CPU can
read and write to those memory locations or cells.

Technically, bit is electrical states of off or on OR high or low in computer circuitry. Each
binary digit is represented by an electrical pulse. The bit ‘1’ represents the presence of
electrical pulse. The bit ‘0’ represents the absence of electrical pulse. Therefore, the
representation of individual character is a series of electrical pulse.

Bit is the most basic unit of information in digital computers. A bit is represented in digital
computers by physical quantities called signals. Electrical signals such as voltage exist
throughout the computer in either one of two recognizable states described above. The
manipulation of binary information is done by logic circuits called gates. Gates are blocks of
hardware that produce signals of binary 1 or 0 when input logic requirements are satisfied. A
variety of logic gates are used in digital systems. Each gate has distinct graphic symbol and
its operation can be described by means of algebraic expression.

 Bits – is sequence of binary digits.


 Nibble – a group of 4 bits is called nibble. Nibble is half a byte.
 Byte – is a group of eight bits.
 Word – is a sequence of bits of fixed size or length. Words can be 16 bits, 32 bits, 64
bits, or any other size that makes sense within the context of a computer’s
organization. [A computer whose word size is 64 bits, typically called 64 bit machine,
is capable of fetching 64 bit of data/instruction from main memory].

Manufacturers of computer storage devices express the capacity of such devices in terms of
the number of bytes they can hold. Today, even the bandwidth for internet connectivity is
measured in bytes.

Kilo represents 2 to the power , i.e, 210 = 1024.

2
ATBU Bauchi, DMS_ CS211 Note. 2017/2018

 1 Byte = 8 bits
 1KB = 210 bytes = 1024 bytes i.e, thousands of bytes
 1MB = 210 KB = 1024KB = (1024 × 1024 bytes) i.e, millions of bytes
 1GB = 1024MB i.e, billions of bytes
 1TB = 1024GB

The memory of 640KB has 655,360 bytes.

640KB = 640x1024 = 655,360 bytes

A RAM whose capacity is 256MB roughly has 256 million bytes.

256MB = 256 × 1024 = 262144 KB

262144 KB = 262144 × 1024 = 268,435,456 bytes

Exercise: Work out the number of bytes of a memory card whose capacity is 1.5GB.

Memory cards, Flash drives, RAM and Hard Disk Drive of modern computers are
available usually in gigabytes.eg 4GB RAM, 500GB

Beside binary number system, the Octal (base 8) and Hexadecimal (base 16) are important
in digital computer work. Octal and Hexadecimal number systems are used because they
provide nice way to abbreviate long string of binary digits. The word size (word length) may
abbreviated with octal digits (each octal digit represents three binary digits), or with
hexadecimal digits (each octal digit represents four binary digits).

Octal is sometimes used in computing instead of hexadecimal; perhaps most often in modern
times in conjunction with file permissions under Unix systems (see chmod). It has the
advantage of not requiring any extra symbols as digits (the hexadecimal system is base-16
and therefore needs six additional symbols beyond 0–9). While Octal is another type of
digital numbering system, it is little used these days instead Hexadecimal Numbering System
is commonly used as it is more flexible. Two hexadecimal digits exactly specify one byte.

NUMBER SYSTEM

A number system of base r is a system that uses distinct symbols for r digits. The number
systems that are of interest in Computer Science are binary and hexadecimal. To distinguish
between different bases, the base is written as a subscript.

Base System
Decimal The decimal system is base 10. The digits in decimal system are: 0, 1, 2,
3, 4, 5, 6, 7, 8, 9. Decimal number system is used by humans in their
daily activities to express quantities.

Binary Binary is base 2. There are only 2 digits 0, and 1 called binary digits
(bits). Example of number expressed in binary is:
 1011012

3
ATBU Bauchi, DMS_ CS211 Note. 2017/2018

Octal Octal is base 8. It is also used for representing binary digits. There are 8
digits: 0, 1, 2, 3, 4, 5, 6, 7. Example of number expressed in octal is:
 5628
Hexadecimal Hexadecimal is base 16. It is very useful for representing binary data
concisely! There are 16 digits 0 to 15:

.
 F2EA16

POSITIONAL NUMBERING SYSTEM

The general idea behind positional numbering systems is that a numeric value is represented
through increasing powers of a radix (or base). This is often referred to as a weighted
numbering system because each position is weighted by a power of the radix.

The basic idea is that a numeric value is represented through increasing power of a radix or
base. Each position is weighted by a power of the radix.
The following table shows the position and weight.
n …. 3 2 1 0 POSITION
n 3 2 1 0
Binary 2 …. 2 2 2 2 =1
n 3 2 1
Octal 8 …. 8 8 8 80 = 1 WEIGHT
n 3 2 1 0
Hexa 16 ….. 16 16 16 16 = 1

24310 = 2×102 + 4×101 + 3 ×100 = 24310

101102 = 1×24 + 0×23 + 1×22 + 1×21 + 0×20 = 2210

Conversion of decimal integer to Base n

One of the simplest methods of converting decimal digits to base n is division-remainder


method. The division-remainder method is faster and easier. It employs the idea of successive
divisions by the base. The remainders that we get when we sequentially divide by the base
end up being the digits of the result, which are read from bottom to top. This method is
illustrated in Examples ….

Example 1: Convert 510 to binary Example 2: Convert 17810 to base 8 (octal)


2 5 remainder 8 178 remainder
2 2 1 8 22 2
2 1 0 8 2 6
0 1 0 2
510 = 1012 17810 = 2628

4
ATBU Bauchi, DMS_ CS211 Note. 2017/2018

Example 3: Convert 57410 to base 16 (Hexadecimal) Example 4: Convert 7610 to binary


16 574 remainder 2 76 remainder
16 35 14 => E 2 38 0
16 2 3 2 19 0
0 2 2 9 1
57410 = 23E16 2 4 1
2 2 0
2 1 0
0 1
7610 = 10011002

Generally, with N bits, the range of unsigned integers that can be represented is 0 to 2 N – 1.
For example, 4 bits can represent the decimal values 0 to 15, while 8 bits can represent the
values 0 through 255. The range of values that can be represented by a given number of bits
is extremely important when doing arithmetic operations on binary numbers.

Conversion of decimal fractions to Base n

Fractions in any base system can be approximated in any other base system using negative
powers of a radix. Radix points separate the integer part of a number from its fractional part.
In the decimal system, the radix point is called a decimal point. Binary fractions have a
binary point.

Fractions that contain repeating strings of digits to the right of the radix point in one base
may not necessarily have a repeating sequence of digits in another base. For instance, 2/3 is a
repeating decimal fraction, but in the ternary system it terminates as 0.23 (2×3-1 = 2×1 3).

We can convert decimal fractions to base n using method analogous to the division-remainder
methods for converting integers. However, here we repeatedly multiply the fractional part by
n until the result is 0. The integer part of the multiplication process is then picked and read
from top to bottom. The following is an example

Example 5: Convert 0.430410 to base 5 Example 6: Convert Example 7: Convert


0.687510 to binary 0.12510 to binary
.6875 .125
x 2 x 2
1. 3 7 5 0 0. 2 5 0
x 2 x 2
0. 7 5 0 0 0. 5 0 0
x 2 x 2
1. 5 0 0 0 1. 0 0 0
x 2
1. 0 0 0 0 0.12510 = 0.0012
0.687510 = 0.10112

5
ATBU Bauchi, DMS_ CS211 Note. 2017/2018

Example 8: Convert 23.75010 to binary. Example 9: Convert 0.3437510 to binary with 4


We first convert the integer part (i.e, 23) bits to the right of the binary point (i.e, to 4 binary
separately to binary and then convert places).
the fractional part (.750)
.750
x 2

1. 5 0 0
x 2

1. 0 0 0

2310 = 101112
Therefore, 23.75010 = 10111.112
Reading from top to bottom, 0.3437510 = 0.0101 to
four binary places
Conversion from Base n to Decimal
To convert a given number expressed in base n to decimal, we used the positional numbering
system (also called weighted numbering system) described above.
Example 10: Convert 1012 to decimal
Solution
(1×22) + (0×21) + (1×20) => 4 + 0 + 1 = 5
Therefore, 1012 = 510
Example 11: Convert 10011002 to decimal
Solution
(1×26) + (0×25) + (0×24) + (1×23) + (1×22) + (0×21) + (0×20)
64 + 0 + 0 + 8 + 4 + 0 +0 = 76
Therefore, 10011002 = 7610
Example 12: Convert 23E16 to decimal
Solution
(2×162) + (3×161) + (14×160) => 512 + 48 + 14 = 574
Therefore, 23E16 = 57410
Alternatively, you can convert 23E16 to binary and then convert the binary to decimal
Example 13: Convert 10101.10112 to decimal
Solution
(1×24) + (0×23) + (1×22) + (0×21) + (1×20) + (1×2-1) + (0×2-2) + (1×2-3) + (1×2-4)
16 + 0 + 0 + 4 + 0 + 1 + + 0 + + = 21 + 0.5 + 0.125 + 0.0625 = 21.6875
Therefore, 10101.10112 = 21.687510
Note: the numbering of position of the fractional part starts from -1

Conversion from Binary to Hexadecimal

6
ATBU Bauchi, DMS_ CS211 Note. 2017/2018

To convert binary numbers to hexadecimal, organise the bits into group of 4 and replace them
with their hexadecimal equivalent. We start grouping the bits from the LSB (Least Significant
Bit) or the rightmost bit.
Example 14: Convert 10111012 to hexadecimal

Solution

Start counting the digits from the right most bit (least significant bit).

0101 1101
01012 = 5, and 1101 = 13 => D

Therefore, 10111012 = 5D16


Example 15: Convert 10110010112 to hexadecimal

Solution

0010 1100 1011


00102 = 2, 1100 = C (ie, 12), 10112 = B (ie, 11)
Therefore, 10110010112 = 2CB16
Conversion from Hexadecimal to Binary
To convert hexadecimal to binary, simply find the binary equivalent of each digit of the
hexadecimal.
Example 16: Convert 7E2F16 to binary
Solution
7 = 0111, E => 14 = 1110, 2 = 0010, F => 15 = 1111
Therefore, 7E2F16 = 01111110001011112
Conversion from Binary to Octal
To convert binary numbers to octal, organise the bits into group of 3 and replace them with
their octal equivalent. We start grouping the bits from the LSB (Least Significant Bit) or the
rightmost bit.
Example 17: Convert 100111102 to hexadecimal

Solution

Start counting the digits from the right most bit (least significant bit).

010 011 110


0102 = 2, and 011 = 3 , 110= 6

Therefore, 100111102 = 2368


Conversion from Octal to Binary is done similar to the way Hexadecimal is converted to
binary.
Conversion between bases is summarized by the following figure

7
ATBU Bauchi, DMS_ CS211 Note. 2017/2018

Exercise
Given the following bits 1100100111012, what is the octal and hexadecimal equivalent?
Answer: 62358 and C9D16 Please verify.

SIGNED INTEGER REPRESENTATION


Signed integers are integers with negative sign. The problem with representing signed
integers as binary values is the sign – how should we encode the actual sign of the number?
The following are methods of representing signed integers.
i. Sign Magnitude
ii. One’s Complement
iii. Two’s Complement
Generally, the range of integers that can be represented using n bits is: -2(n-1) – 1 to +2(n-1) – 1
Signed Magnitude
In this method, the leftmost bit or the most significant bit (MSB) is reserved for the sign of a
number while the remaining bits represent the magnitude (number). The bit ‘1’ represents
negative sign while ‘0’ represents positive sign. In a computer the uses this method and 8 bits
to represent number, only 7 bits can be used to represent the magnitude of the number. This
means the largest integer that can be represented is 27 – 1, that is -127 to +127.
Example 18: Use signed magnitude method and 8 to represent -6.
Solution
We first find the binary equivalent of 6.
+6 = 00000110
-6 = 10000110
Computers must be able to perform arithmetic calculations on integers that are represented
using this notation.
When performing arithmetic operations using signed magnitude, the rule is we cannot ‘carry
into’ the signed bit (i.e, leftmost bit). Assume we are using 8 bits and the leftmost bit is
reserve for the sign. If there is carry emitting from the 7th bit, the result will be truncated
thereby leading to wrong answer as the 7th bit overflows. Example 17 illustrates the overflow
situation. This is the major disadvantage or limitation of this method. Another disadvantage is
there are two different representations for zero. +0 = 00000000, -0 =10000000.
When the actual result of an arithmetic operation is outside the representable range, an
arithmetic overflow has occurred.

One’s complement
To represent signed integers using one’s complement, the following steps are essential
i. Obtain the binary equivalent of the integer, and

8
ATBU Bauchi, DMS_ CS211 Note. 2017/2018

ii. Flip the bits (change 1 to 0, and 0 to 1)


Example 20: Use 8 bits, and one’s complement method to represent -610.
Solution
We first find the binary equivalent of 6.
+610 = 000001102
Flip the bits. That is, change 1 to 0 and 0 to 1.
-610 = 111110012
Example 21: Use 8 bits, and one’s complement method to -13.

Solution
We first find the binary equivalent of 13.
+13 = 00001101
Flip the bits. That is, change 1 to 0 and 0 to 1.
-13= 11110010
Like signed magnitude, one’s complement is not used on modern computers.
Two’s Complement
To represent a signed number using two’s complement,
i. Obtain the binary equivalent of the integer, and
ii. Flip the bits (change 1 to 0, and 0 to 1).
iii. Add 1 to the flipped bits
iv. If there is any bit ‘carried’ from the MSB, we simply discard or ignore it.
Example 22: Use 8 bits and two’s complement method to represent -1610.
Solution
We first find the binary equivalent of 16.
+1610 = 000100002
Flip the bits. That is, change 1 to 0 and 0 to 1.
-1610 = 11101111 + 1 = 111100002
Unlike signed magnitude and one’s complement methods, in two’s complement there is only
one representation of 0.
+0 = 00000000.
Flip the bits. That is, change 1 to 0, and 0 to 1
-0 = 11111111
Add 1 to the flipped bits. => 11111111 + 1
=> 1 00000000.
Note that there is a bit ‘carried’ out of the MSB (8th bit position). We simply discard it.
Modern computer adopted the two’s complement method to perform arithmetic operations.

REPRESENTATION OF FLOATING-POINT NUMBERS


In scientific notation, numbers are expressed in two parts: a fractional part, called a mantissa,
and an exponential part that indicates the power of ten to which the mantissa should be raised
to obtain the value we need. So to express 32767 in scientific notation, we could write
3.2767×104. Scientific notation simplifies pencil and paper calculations that involve very
large or very small numbers. It is also the basis for floating-point computation in today’s
digital computers.

9
ATBU Bauchi, DMS_ CS211 Note. 2017/2018

To express it in ±M × BE, we have to normalize it. A floating point number is said to be


normalize if the first digit after the radix point is non-zero.
A non-normalize number can be normalized by shifting the radix point in the mantissa to the
left or right and decreasing or increasing the exponent by a number of positions shifted.
For example, 65.75 = 0.6575 × 102
In digital computers, floating-point numbers consist of three parts:
 a sign bit,
 an exponent part (representing the exponent on a power of 2), and a
 fractional part called a significand (which is a fancy word for a mantissa).
The number of bits used for the exponent and significand depends on whether we would like
to optimize for range (more bits in the exponent) or precision (more bits in the significand).
The following table shows a cell in memory that stores a floating point value. The cell is
divided into three fields. The first field stores one bit for the sign of the number. The second
field stores the bits representing the exponent of the normalized binary number. The third
field, called the mantissa or significand, stores bits that represent the magnitude of the value.
The exponent determines the shift of the binary point in the binary representation of the
mantissa.
Sign Exponent Mantissa (significand)
In general, a floating point number can be positive or negative and its exponent can be
positive or negative as well. You might think that two’s complement method would be used
because most computers use it to store signed integers. However, here two’s complement is
not used to represent the exponent. Instead, a biased representation is used.
Biased System (2n-1 Excess)
The idea of using a bias value is to convert every integer into a non-negative integer which is
then represented in binary.
Using n bits, the biased representation of an integer N is giving by N + 2n-1. Thus each
representation is 2n-1 excess in the value it represents.
Example 23: Using 8 bits and biased system, find representation of 5, and -7
Solution
n=8
i. N = 5. => 5 + 28-1 => 5 + 128 = 13310 = 100001012. Therefore, 5 is
represented by 100001012 in biased form
ii. N = -7. => -7 + 28-1 => -7 + 128 = 12110 = 011110012. Therefore, -7 is
represented by 011110012 in biased form

The Institute of Electrical and Electronic Engineers (IEEE) published a standard called IEEE-
754 for representing floating point numbers. The IEEE standard specifies the number of bits
to be used when representing floating point numbers. The IEEE-754 sardard I divided into 2.
i. IEEE Single precision – It uses 32 bits. 8 bits for exponent, 23 bits for mantissa
(significand) and 1 bit for the sign. Therefore, single precision uses an excess 127 bias
over 8 bit exponent.
ii. IEEE double precision – It uses 64 bits. 11 bits for exponent, 53 bits for the mantissa
(significand) and 1 bit for the sign. The bias is 1023.
10
ATBU Bauchi, DMS_ CS211 Note. 2017/2018

Example 26: Use IEEE single precision to represent 52.6875


Solution
Since the number is positive, Sign bit is 0.
Convert the integer and the fractional parts to binary.
52 = 110100 and 0.6875 = 0.1011
52.6875 = 110100.1011
When 110100.1011 is normalized, we should have 0.1101001011 × 2 6
The exponent is 6.
The biased form of 6 is: 6 + 28-1 => 6 + 128 = 13410 = 100001102
Therefore, the computer representation of 52. 6875 is:
0 10000110 1101001011
Sign exponent Significand

CHARACTER REPRESENTATION
In the previous sections, we have seen how numbers are represented in computer. Obviously
numbers are not the only characters that computer represents. In addition to numbers,
computers also represent lower and upper case letters (a-z ; A-Z), special symbols such as
punctuation marks, &, <, etc, these all together are referred to alphanumeric. Alphanumeric
data are represented by assigning a unique binary code or sequence of bits to represent each
character. As character is entered through keyboard or any other input device is converted
into binary code. The encoding schemes used to represent character in computer system are

i. BCD – Binary Coded Decimal


ii. ASCII – American Standard Code for Information Interchange
iii. EBCDIC – Extended Binary Coded Decimal Interchange Code
iv. Unicode
EBCDIC
It uses 8-bit code, and can represent 28 =256 characters. Thus in EBCDIC, a byte is used to
represent a character. Remember a byte has two nibbles. The upper nibble represents the zone
bits; while the lower nibble represent the numeric values. Characters are represented by
appending numeric (digit) bits to zone bits. The table below shows the zone bits and numeric
digits for some characters.
For example, the character a is 1000 0001 and the digit 3 is 1111 0011 in EBCDIC. Note the
only difference between upper and lowercase characters is in bit position 2, making a
translation from upper to lowercase (or vice versa) a simple matter of flipping one bit.

11
ATBU Bauchi, DMS_ CS211 Note. 2017/2018

ASCII
ASCII (pronounced "AS-key"), defines codes for control characters, digits, letters (upper-
and lowercase), special characters (such as $ and #), and the space character. It has two
versions. The first version uses 7-bit code to represent 27 = 128 different for characters. The
second version, which is more common, uses 8 bits to represent 256 different characters. For
all practical purposes an 8 bit code is used. The eight bit which the MSB is used for parity. A
parity bit is turned “on” or “off” depending on whether the sum of the other bits in the byte is
even or odd. Parity is the most basic of all error detection schemes. For example, if we decide
to use even parity and we are sending an ASCII A, the lower 7 bits are 1000001. Because the
sum of the bits is even, the parity bit would be set to off and we would transmit 0100 0001.
Similarly, if we transmit an ASCII C, 100 0011, the parity bit would be set to on before we
sent the 8-bit byte, 1100 0011.
The ASCII representation has been adopted as a standard by the U.S. government and is
found in a variety of computers, particularly minicomputers and microcomputers.
Like EBCDIC, the 8 bits used to represent a character are partitioned into two groups; zone
bits and numeric bits. The following table shows the zone and numeric bits for some
character.

ASCII – 8 codes
Characters Decimal Zone bits Numeric bits
A–O 65 – 79 0100 0001 – 1111
P–Z 80 – 90 0101 0000 – 1010
a–o 97 – 111 0110 0001 – 1111
p–z 112 – 122 0111 0000 – 1010
0–9 48 – 57 0011 0000 – 1001

Comprehensive list of ASCII characters set can be found on the internet – specifically,
Wikipedia. https://en.wikipedia.org/wiki/ASCII
Example 27: Using ASCII, what are the bits that represent CS232
Method I
C => 3 = 0011, zone bits = 0100, => 0100 0011
S => 3 = 0011, zone bits = 0101 => 0101 0011

12
ATBU Bauchi, DMS_ CS211 Note. 2017/2018

2 => 0010, zone bits = 0011 = 0011 0010


3 => 0011, zone bits = 0011 = 0011 0011
The bits for CS232 using ASCII are:
01000011 01010011 00110010 00110011 00110010
Method II
C = 67 = 1000011, S = 83 = 1010011, 2 = 50 =110010, 3 = 51 = 110011
Since ASCII requires 8 bits for each character and obviously some the bits above are not up
to 8, we have to complete. Thus the bits for CS232 is:
01000011 01010011 00110010 00110011 00110010
Exercise: Represent Ali2 using ASCII.
Unicode
Both EBCDIC and ASCII were built around the Latin alphabet. As such, they are restricted in
their abilities to provide data representation for the non-Latin alphabets used by the majority
of the world’s population. As all countries began using computers, each was devising codes
that would most effectively represent their native languages. None of these were necessarily
compatible with any others, placing yet another barrier in the way of the emerging global
economy.
In 1991, before things got too far out of hand, a consortium of industry and public leaders
was formed to establish a new international information exchange code called Unicode. This
group is appropriately called the Unicode Consortium.
Unicode is a 16-bit alphabet that is downward compatible with ASCII and the Latin-1
character set. It is conformant with the ISO/IEC 10646-1 international alphabet. Because the
base coding of Unicode is 16 bits, it has the capacity to encode the majority of characters
used in every language of the world. If this weren’t enough, Unicode also defines an
extension mechanism that will allow for the coding of an additional million characters. This
is sufficient to provide codes for every written language in the history of civilization.

Representation of pictures & graphic data


A picture is made up of small dots called pixels of different colours. Thus a grid of pixels
represents computer graphic data like pictures, frames of a movie, drawings, or frames of an
animation are made of several pixel. Pixel" is short for picture element. In simple graphics
(those without many colors), a byte can represent a single pixel. However, Modern video
games and colorful graphics use several bytes for each pixel. A scanned photograph or a jpeg
image is thus stored as thousands of bytes - each byte, or collection of bytes, representing a
pixel.
A pixel has colour. Any colour can be made with the combination of different degrees of
primary colours – red, green and blue. These can be represented as RGB (Red, Green, Blue)
and the value of any colour ranges from 0 to 255.
Thus, representation of a particular pixel is simply the RGB values of the color for that pixel.
For instance, suppose the color of a particular pixel dark purple colour. It’s RGB values are
“135, 31, 120” (Figure 3.4). The binary values of the numbers for colour combination are
then encoded as the representation of that pixel.
Two common graphics formats used particularly on the Internet are JPEG and GIF. JPEG and
GIF are also compressed formats. This means that instead of storing every pixel, a file of this

13
ATBU Bauchi, DMS_ CS211 Note. 2017/2018

format stores the patterns of pixels. By storing just the patterns and not every pixel, JPEG and
GIF file formats are often many times less bytes than a corresponding bitmap format of the
graphic would be. This makes JPEG and GIF much better suited to storing on the small flash
cards of digital cameras or for downloading over the relatively slow Internet.
Representation of Sound
Sound occurs naturally as an analog wave. However, all data in digital computer are must be
represented in digital form – those made of bytes. Hence, sound which comes as an analog
data must converted to a digital data, a process called analog to digital conversion. After
conversion, sound is then represented in a bits pattern made of 0s and 1s. The following
figure show how the intensity of the sound signal can be represented to digital form

To convert an analog wave into digital, converters use a process called sampling. They
sample the height of the sound wave at regular intervals of time, often small fractions of a
second. If one byte is used to hold a single sample of an analog wave, then the wave can be
one of 256 different heights (0 being the lowest height and 255 being the highest). These
heights represent the decibel level of the sound. Thus a spoken word might occupy several
hundred bytes - each being a sample of the sound wave of the voice at a small fraction of a
second. If these 100 bytes were sent to a computer's speaker, the spoken word would be
reproduced.

14

You might also like