[go: up one dir, main page]

0% found this document useful (0 votes)
5 views70 pages

Ch-03 Data Storage (Compatibility Mode)

The document outlines the fundamentals of data storage in computers, covering various data types such as integers, reals, text, audio, images, and video. It explains how these data types are represented in binary form, including methods for storing signed and unsigned integers, such as fixed-point, sign-and-magnitude, and two's complement representations. Additionally, it discusses data compression techniques to optimize memory usage.
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)
5 views70 pages

Ch-03 Data Storage (Compatibility Mode)

The document outlines the fundamentals of data storage in computers, covering various data types such as integers, reals, text, audio, images, and video. It explains how these data types are represented in binary form, including methods for storing signed and unsigned integers, such as fixed-point, sign-and-magnitude, and two's complement representations. Additionally, it discusses data compression techniques to optimize memory usage.
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/ 70

SWISS GERMAN UNIVERSITY

3
Data
Storage
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 1


19-Apr-16 Foundations of Computer Science Cengage Learning
SWISS GERMAN UNIVERSITY

Objectives
After studying this chapter, the student should be able to:
 List five different data types used in a computer.
 Describe how different data is stored inside a computer.
 Describe how integers are stored in a computer.
 Describe how reals are stored in a computer.
 Describe how text is stored in a computer using one of the various
encoding systems.
 Describe how audio is stored in a computer using sampling, quantization
and encoding.
 Describe how images are stored in a computer using raster and vector
graphics schemes.
 Describe how video is stored in a computer as a representation of images
changing in time.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 2


19-Apr-16
SWISS GERMAN UNIVERSITY

Previous Lecture ….
 A number system that uses distinct symbols to represent a
number can be categorized as positional and nonpositional
number system.
 Positional number system is divided into 4 categories:
binary, octal, decimal and hexadecimal number system

 Conversion from decimal to any base number system


(integer or real number) can be done by dividing the integral
part, and determine the remainder of quotients, and then
multiplying the fractional part and determine the integer part
of the fraction.

 Conversion from any base to decimal number system can be


done by calculating the number value.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 3


19-Apr-16
3-1 INTRODUCTION SWISS GERMAN UNIVERSITY

Data today comes in different forms including numbers,


text, audio, image and video
video..

Different types of data


i
The computer industry uses the term “multimedia” to
define information that contains numbers,
text, images, audio and video.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 4


19-Apr-16
SWISS GERMAN UNIVERSITY

Data inside the computer


All data types are transformed into a uniform representation when
they are stored in a computer and transformed back to their
original form when retrieved. This universal representation is
called a bit pattern.

A bit pattern

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 5


19-Apr-16
SWISS GERMAN UNIVERSITY

Storage of different data types


QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 6


19-Apr-16
SWISS GERMAN UNIVERSITY

Data compression
To occupy less memory space, data is normally compressed before
being stored in the computer. Data compression is a very broad and
involved subject, so we have dedicated the whole of Chapter 15 to
the subject.

i
Data compression is discussed in Chapter 15.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 7


19-Apr-16
3-2 STORING NUMBERS SWISS GERMAN UNIVERSITY

A number is changed to the binary system before being


stored in the computer memory, as described in Chapter 2.
However, there are still two issues that need to be handled
handled::

1. How to store the sign of the number


number..
2. How to show the decimal point
point..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 8


19-Apr-16
SWISS GERMAN UNIVERSITY

Storing integers
Integers are whole numbers (numbers without a fractional part).
For example, 134 and −125 are integers, whereas 134.23 and
−0.235 are not. An integer can be thought of as a number in
which the position of the decimal point is fixed: the decimal
point is to the right of the least significant (rightmost) bit. For
this reason, fixed-point representation is used to store an integer.
In this representation the decimal point is assumed but not
stored.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 9


19-Apr-16
SWISS GERMAN UNIVERSITY

Fixed point representation of integers

i
An integer is normally stored in memory using
fixed-point representation.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 10


19-Apr-16
SWISS GERMAN UNIVERSITY

Unsigned representation
An unsigned integer is an integer that can never be negative and
can take only 0 or positive values. Its range is between 0 and
positive infinity.

An input device stores an unsigned integer using the following


steps:
1. The integer is changed to binary.
2. If the number of bits is less than n, 0s are added to the left.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 11


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.1
Store 7 in an 8-bit memory location using unsigned
representation..
representation
Solution
First change the integer to binary, (111
111))2. Add five 0s to make a
total of eight bits, (00000111
00000111))2. The integer is stored in the
memory location
location.. Note that the subscript 2 is used to emphasize
that the integer is binary, but the subscript is not stored in the
computer..
computer

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 12


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.2
Store 258 in a 16
16--bit memory location
location..

Solution
First change the integer to binary (100000010
100000010))2. Add seven 0s to
make a total of sixteen bits, (0000000100000010
0000000100000010))2. The integer is
stored in the memory location
location..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 13


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.3
What is returned from an output device when it retrieves the bit
string 00101011 stored in memory as an unsigned integer?

Solution
Using the procedure shown in Chapter 2, the binary integer is
converted to the unsigned integer 43
43..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 14


19-Apr-16
SWISS GERMAN UNIVERSITY

Figure 3.5 shows what happens if we try to store an integer that is


larger than 24 − 1 = 15 in a memory location that can only hold four
bits.

Overflow in unsigned integers


QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 15


19-Apr-16
SWISS GERMAN UNIVERSITY

Sign-and-magnitude representation
In this method, the available range for unsigned integers (0 to 2n − 1)
is divided into two equal sub-ranges. The first half represents
positive integers, the second half, negative integers.

Sign-and-magnitude representation

i
In sign-and-magnitude representation, the leftmost
bit defines the sign of the integer. If it is 0, the integer
is positive. If it is 1, the integer is negative.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 16


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.4
Store +28 in an 8-bit memory location using sign
sign--and
and--magnitude
representation..
representation

Solution
The integer is changed to 7-bit binary
binary.. The leftmost bit is set to 0.
The 8-bit number is stored
stored..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 17


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.5
Store -28 in an 8-bit memory location using sign
sign--and
and--magnitude
representation..
representation

Solution
The integer is changed to 7-bit binary
binary.. The leftmost bit is set to 1.
The 8-bit number is stored
stored..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 18


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.6
Retrieve the integer that is stored as 01001101 in sign
sign--and
and--
magnitude representation
representation..

Solution
Since the leftmost bit is 0, the sign is positive
positive.. The rest of the bits
(1001101
1001101)) are changed to decimal as 77 77.. After adding the sign,
the integer is +77
77..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 19


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.7
Retrieve the integer that is stored as 10100001 in sign
sign--and
and--
magnitude representation
representation..

Solution
Since the leftmost bit is 1, the sign is negative
negative.. The rest of the bits
(0100001
0100001)) are changed to decimal as 33 33.. After adding the sign,
the integer is −33
33..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 20


19-Apr-16
SWISS GERMAN UNIVERSITY

Figure below shows both positive and negative overflow when storing an
integer in sign-and-magnitude representation using a 4-bit memory location.

Overflow in sign-and-magnitude representation QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 21


19-Apr-16
SWISS GERMAN UNIVERSITY

Two’s complement representation


Almost all computers use two’s complement representation to store a
signed integer in an n-bit memory location. In this method, the
available range for an unsigned integer of (0 to 2n − 1) is divided into
two equal sub-ranges. The first sub-range is used to represent
nonnegative integers, the second half to represent negative integers.
The bit patterns are then assigned to negative and nonnegative (zero
and positive) integers

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 22


19-Apr-16
SWISS GERMAN UNIVERSITY

Two’s complement representation

i
In two’s complement representation, the leftmost bit
defines the sign of the integer. If it is 0, the integer is
positive. If it is 1, the integer is negative.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 23


19-Apr-16
SWISS GERMAN UNIVERSITY

One’s Complementing
Before we discuss this representation further, we need to introduce two
operations. The first is called one’s complementing or taking the one’s
complement of an integer. The operation can be applied to any integer,
positive or negative. This operation simply reverses (flips) each bit. A 0-
bit is changed to a 1-bit, a 1-bit is changed to a 0-bit.

Example 3.8
The following shows how we take the one’s complement of the
integer 00110110
00110110..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 24


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.9
The following shows that we get the original integer if we apply
the one’s complement operations twice
twice..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 25


19-Apr-16
SWISS GERMAN UNIVERSITY

Two’s Complementing
The second operation is called two’s complementing or taking the
two’s complement of an integer in binary. This operation is done in
two steps. First, we copy bits from the right until a 1 is copied;
then, we flip the rest of the bits.

Example 3.10
The following shows how we take the two’s complement of the
integer 00110100
00110100..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 26


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.11
The following shows that we always get the original integer if we
apply the two’s complement operation twice
twice..

i
An alternative way to take the two’s complement of
an integer is to first take the one’s complement and
then add 1 to the result.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 27


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.12
Store the integer 28 in an 8-bit memory location using two’s
complement representation
representation..

Solution
The integer is positive (no sign means positive), so after decimal
to binary transformation no more action is needed
needed.. Note that three
extra 0s are added to the left of the integer to make it eight bits
bits..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 28


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.13
Store −28 in an 8-bit memory location using two’s complement
representation..
representation

Solution
The integer is negative, so after changing to binary, the computer
applies the two’s complement operation on the integer
integer..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 29


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.14
Retrieve the integer that is stored as 00001101 in memory in
two’s complement format
format..

Solution
The leftmost bit is 0, so the sign is positive
positive.. The integer is
changed to decimal and the sign is added
added..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 30


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.15
Retrieve the integer that is stored as 11100110 in memory using
two’s complement format
format..
Solution
The leftmost bit is 1, so the integer is negative
negative.. The integer needs
to be two’s complemented before changing to decimal
decimal..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 31


19-Apr-16
SWISS GERMAN UNIVERSITY

Overflow in two’s complement representation


i
There is only one zero in two’s complement notation.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 32


19-Apr-16
SWISS GERMAN UNIVERSITY

Comparison

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 33


19-Apr-16
SWISS GERMAN UNIVERSITY

Storing reals
A real is a number with an integral part and a fractional part. For
example, 23.7 is a real number—the integral part is 23 and the
fractional part is 7/10. Although a fixed-point representation can be
used to represent a real number, the result may not be accurate or it
may not have the required precision. The next two examples
explain why.

i
Real numbers with very large integral parts or very
small fractional parts should not be stored in fixed-
point representation.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 34


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.16
In the decimal system, assume that we use a fixed fixed--point representation
with two digits at the right of the decimal point and fourteen digits at the
left of the decimal point, for a total of sixteen digits
digits.. The precision of a
real number in this system is lost if we try to represent a decimal number
such as 1.00234
00234:: the system stores the number as 1.00
00..

Example 3.17
In the decimal system, assume that we use a fixed fixed--point representation
with six digits to the right of the decimal point and ten digits for the left of
the decimal point, for a total of sixteen digits
digits.. The accuracy of a real
number in this system is lost if we try to represent a decimal number such
as 236154302345
236154302345..00 00.. The system stores the number as 6154302345
6154302345..0000::
the integral part is much smaller than it should be
be..
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 35


19-Apr-16
SWISS GERMAN UNIVERSITY

Floating-point representation
The solution for maintaining accuracy or precision is to use
floating-point representation.

The three parts of a real number in floating-point representation

i
A floating point representation of a number is made up of
three parts: a sign, a shifter and a fixed-point number.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 36


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.18

The following shows the decimal number

7,452
452,,000
000,,000
000,,000
000,,000
000,,000
000,,000
000..00

in scientific notation (floating


(floating--point representation)
representation)..

The three sections are the sign (+), the shifter (21
21)) and the fixed
fixed--
point part (7.425
425)). Note that the shifter is the exponent
exponent..
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 37


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.19
Show the number
−0.0000000000000232
in scientific notation (floating
(floating--point representation)
representation)..
Solution
We use the same approach as in the previous example
example— —we move
the decimal point after the digit 2, as shown below
below::

The three sections are the sign (-), the shifter (-14 14)) and the
fixed--point part (2.32
fixed 32)). Note that the shifter is the exponent
exponent..
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 38


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.20

Show the number


(101001000000000000000000000000000
101001000000000000000000000000000..00
00))2
in floating
floating--point representation
representation..

Solution
We use the same idea, keeping only one digit to the left of the
decimal point
point..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 39


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.21

Show the number


−(00.00000000000000000000000101
−( 00000000000000000000000101))2
in floating
floating--point representation
representation..

Solution
We use the same idea, keeping only one digit to the left of the
decimal point
point..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 40


19-Apr-16
SWISS GERMAN UNIVERSITY

Normalization
To make the fixed part of the representation uniform, both the scientific
method (for the decimal system) and the floating-point method (for the
binary system) use only one non-zero digit on the left of the decimal
point. This is called normalization. In the decimal system this digit
can be 1 to 9, while in the binary system it can only be 1. In the
following, d is a non-zero digit, x is a digit, and y is either 0 or 1.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 41


19-Apr-16
SWISS GERMAN UNIVERSITY

i
Note that the point and the bit 1 to the left of the fixed-point
section are not stored—they are implicit.

i
The mantissa is a fractional part that, together with the sign, is
treated like an integer stored in sign-and-magnitude
representation.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 42


19-Apr-16
SWISS GERMAN UNIVERSITY

Excess System
The exponent, the power that shows how many bits the decimal
point should be moved to the left or right, is a signed numbernumber..
Although this could have been stored using two’s complement
representation, a new representation, called the Excess system
system,, is
used instead
instead.. In the Excess system, both positive and negative
integers are stored as unsigned integers
integers.. To represent a positive or
negative integer, a positive integer (called a bias) is added to each
number to shift them uniformly to the non non--negative side
side.. The
value of this bias is 2m−1 − 1, where m is the size of the memory
location to store the exponent
exponent..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 43


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.22
We can express sixteen integers in a number system with 4-bit allocation
allocation..
By adding seven units to each integer in this range, we can uniformly
translate all integers to the right and make all of them positive without
changing the relative position of the integers with respect to each other, as
shown in the figure
figure.. The new system is referred to as Excess
Excess--7, or biased
representation with biasing value of 7.

Shifting in Excess representation


QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 44


19-Apr-16
SWISS GERMAN UNIVERSITY

IEEE Standard

IEEE standards for floating-point representation

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 45


19-Apr-16
SWISS GERMAN UNIVERSITY

IEEE Specifications

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 46


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.23
Show the Excess_
Excess_127
127 (single precision) representation of the decimal number
5.75
75..
Solution
a. The sign is positive, so S = 0.
b. Decimal to binary transformation
transformation:: 5.75 = (101101..11
11))2.
c. Normalization:: (101
Normalization 101..11 1011))2 × 22.
11))2 = (1.1011
d. E = 2 + 127 = 129 = (10000001
10000001))2, M = 10111011.. We need to add nineteen
zeros at the right of M to make it 23 bits
bits..
e. The presentation is shown below
below::

The number is stored in the computer as

01000000110110000000000000000000
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 47


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.24
Show the Excess_
Excess_127
127 (single precision) representation of the
decimal number –161
161..875
875..
Solution
a. The sign is negative, so S = 1.
b. Decimal to binary transformation
transformation:: 161
161..875
875== (10100001
10100001..111
111))2.
c. Normalization:: (10100001
Normalization 10100001..111 0100001111))2 × 27.
111))2 = (1.0100001111
d. E = 7 + 127 = 134 = (10000110
10000110))2 and M = (0100001111
0100001111))2.
e. Representation::
Representation

The number is stored in the computer as

11000011001000011110000000000000
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 48


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.25
Show the Excess_
Excess_127
127 (single precision) representation of the
decimal number –0.0234375
0234375..
Solution
a. S = 1 (the number is negative)
negative)..
b. Decimal to binary transformation
transformation:: 0.0234375 = (0.0000011
0000011))2.
c. 0000011))2 = (1.1)2 × 2−6.
Normalization:: (0.0000011
Normalization
d. E = –6 + 127 = 121 = (01111001
01111001))2 and M = (1)2.
e. Representation::
Representation

The number is stored in the computer as


10111100110000000000000000000000
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 49


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 3.26
The bit pattern (11001010000000000111000100001111
11001010000000000111000100001111))2 is
stored in Excess_
Excess_127
127 format
format.. Show the value in decimal
decimal..
Solution
a. The first bit represents S, the next eight bits, E and the
remaining 23 bits, M.

b. The sign is negative


negative..
c. The shifter = E − 127 = 148 − 127 = 21 21..
d. 00000000111000100001111))2 × 221.
This gives us (1.00000000111000100001111
e. The binary number is (1000000001110001000011
1000000001110001000011..11
11))2.
f. The absolute value is 2,104
104,,378
378..75
75..
g. The number is −2,104
104,,378
378..75
75..
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 50


19-Apr-16
SWISS GERMAN UNIVERSITY

Overflow and Underflow

Overflow and underflow in floating-point representation of reals

Storing Zero
A real number with an integral part and the fractional part set to zero, that is, 0.0,
cannot be stored using the steps discussed above
above.. To handle this special case, it is
agreed that in this case the sign, exponent and the mantissa are set to 0s.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 51


19-Apr-16
SWISS GERMAN UNIVERSITY
3-3 STORING TEXT

A section of text in any language is a sequence of symbols


used to represent an idea in that language
language.. For example, the
English language uses 26 symbols (A, B, C, C,……, Z) to represent
uppercase letters, 26 symbols (a, b, c, …, z) to represent
lowercase letters, nine symbols (0, 1, 2, …, 9) to represent
numeric characters and symbols (., ?, :, ; , …, !) to represent
punctuation.. Other symbols such as blank, newline, and tab
punctuation
are used for text alignment and readability
readability..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 52


19-Apr-16
SWISS GERMAN UNIVERSITY

Codes

 ASCII

 Unicode

i
See Appendix A
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 53


19-Apr-16
SWISS GERMAN UNIVERSITY

Properties of ASCII Code


 The first code (00)16 is null character, and non-printable
 The last code (7F)16 is delete character and non-printable
 The space character (20)16 is printable, blank space
 Character code (01)16 to (1F)16 are control characters, non-
printable, mostly used in data communication
 The uppercase letters start from (41)16, the lowercase letters
start from (61)16 the 6th bit in binary is flipped from 0 to 1
 The digits (0 to 9) begin at (30)16, so to numeric character
subtracted with (48)10 = the integer
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 54


19-Apr-16
SWISS GERMAN UNIVERSITY

We can represent each symbol with a bit pattern


pattern.. In other words,
text such as “CATS”, which is made up from four symbols, can
be represented as four n-bit patterns, each pattern defining a
single symbol (Figure 3.14
14)).

Representing symbols using bit patterns

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 55


19-Apr-16
SWISS GERMAN UNIVERSITY

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 56


19-Apr-16
3-4 STORING AUDIO SWISS GERMAN UNIVERSITY

Audio is a representation of sound or music


music.. Audio, by nature,
is different to the numbers or text we have discussed so far
far.. Text
is composed of countable entities (characters)
(characters):: we can count
the number of characters in text
text.. Text is an example of digital
data.. By contrast, audio is not countable
data countable.. Audio is an example
of analog data
data.. Even if we are able to measure all its values in
a period of time, we cannot store these in the computer’s
memory, as we would need an infinite number of memory
locations.. Figure 3.15 shows the nature of an analog signal,
locations
such as audio, that varies with time
time..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 57


19-Apr-16
SWISS GERMAN UNIVERSITY

An audio signal

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 58


19-Apr-16
SWISS GERMAN UNIVERSITY

Sampling
If we cannot record all the values of a an audio signal over an
interval, we can record some of them. Sampling means that we
select only a finite number of points on the analog signal, measure
their values, and record them.

Sampling an audio signal


QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 59


19-Apr-16
SWISS GERMAN UNIVERSITY

Quantization
The value measured for each sample is a real number. This means
that we can store 40,000 real values for each one second sample.
However, it is simpler to use an unsigned integer (a bit pattern) for
each sample. Quantization refers to a process that rounds the value
of a sample to the closest integer value. For example, if the real
value is 17.2, it can be rounded down to 17: if the value is 17.7, it
can be rounded up to 18.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 60


19-Apr-16
SWISS GERMAN UNIVERSITY

Encoding
The quantized sample values need to be encoded as bit patterns.
Some systems assign positive and negative values to samples, some
just shift the curve to the positive part and assign only positive
values.

If we call the bit depth or number of bits per sample B, the number
of samples per second, S, we need to store S × B bits for each
second of audio. This product is sometimes referred to as bit rate,
R. For example, if we use 40,000 samples per second and 16 bits
per each sample, the bit rate is
R = 40,000 × 16 = 640,000 bits per second
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 61


19-Apr-16
SWISS GERMAN UNIVERSITY

Standards for sound encoding


Today the dominant standard for storing audio is MP3 (short for
MPEG Layer 3). This standard is a modification of the MPEG
(Motion Picture Experts Group) compression method used for
video. It uses 44100 samples per second and 16 bits per sample. The
result is a signal with a bit rate of 705,600 bits per second, which is
compressed using a compression method that discards information
that cannot be detected by the human ear. This is called lossy
compression, as opposed to lossless compression: see Chapter 15.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 62


19-Apr-16
3-5 STORING IMAGES SWISS GERMAN UNIVERSITY

Images are stored in computers using two different


techniques:: raster graphics and vector graphics
techniques graphics..

Raster graphics
Raster graphics (or bitmap graphics) is used when we need to
store an analog image such as a photograph. A photograph consists
of analog data, similar to audio information. The difference is that
the intensity (color) of data varies in space instead of in time. This
means that data must be sampled. However, sampling in this case is
normally called scanning. The samples are called pixels (picture
elements).
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 63


19-Apr-16
SWISS GERMAN UNIVERSITY

Resolution
Just like audio sampling, in image scanning we need to decide how
many pixels we should record for each square or linear inch. The
scanning rate in image processing is called resolution. If the
resolution is sufficiently high, the human eye cannot recognize the
discontinuity in reproduced images.

Color depth
The number of bits used to represent a pixel, its color depth,
depends on how the pixel’s color is handled by different encoding
techniques. The perception of color is how our eyes respond to a
beam of light. Our eyes have different types of photoreceptor cells:
some respond to the three primary colors red, green and blue (often
called RGB), while others merely respond to the intensity of light.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 64


19-Apr-16
SWISS GERMAN UNIVERSITY

True-Color
One of the techniques used to encode a pixel is called True-Color,
which uses 24 bits to encode a pixel.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 65


19-Apr-16
SWISS GERMAN UNIVERSITY

Indexed color
The indexed color—or palette color—scheme uses only a portion of
these colors.

Relationship of the indexed color to the True-Color


QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 66


19-Apr-16
SWISS GERMAN UNIVERSITY

For example, a high-quality digital camera uses almost three


million pixels for a 3 × 5 inch photo. The following shows
the number of bits that need to be stored using each scheme:

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 67


19-Apr-16
SWISS GERMAN UNIVERSITY

Standards for image encoding


Several de facto standards for image encoding are in use. JPEG
(Joint Photographic Experts Group) uses the True-Color scheme,
but compresses the image to reduce the number of bits (see Chapter
15). GIF (Graphic Interchange Format), on the other hand, uses
the indexed color scheme.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 68


19-Apr-16
SWISS GERMAN UNIVERSITY

Vector graphics
Raster graphics has two disadvantages: the file size is big and rescaling
is troublesome. To enlarge a raster graphics image means enlarging the
pixels, so the image looks ragged when it is enlarged. The vector
graphic image encoding method, however, does not store the bit
patterns for each pixel. An image is decomposed into a combination of
geometrical shapes such as lines, squares or circles.
For example, consider a circle of radius r. The main pieces of
information a program needs to draw this circle are:
1. The radius r and equation of a circle.
2. The location of the center point of the circle.
3. The stroke line style and color.
4. The fill style and color.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 69


19-Apr-16
3-6 STORING VIDEO SWISS GERMAN UNIVERSITY

Video is a representation of images (called frames


frames)) over time
time.. A
movie consists of a series of frames shown one after another
another.. In
other words, video is the representation of information that
changes in space and in time
time.. So, if we know how to store an
image inside a computer, we also know how to store videovideo:: each
image or frame is transformed into a set of bit patterns and stored
stored..
The combination of the images then represents the video
video..

i
See Chapter 15 for video compression.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 70


19-Apr-16

You might also like