Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 65

INFORMATION

REPRESENTATION
CHAPTER 1
NUMBERS AND QUANTITIES
DECIMAL PREFIX AND BINARY PREFIX
ACTIVITY

• If you have a pen drive of size 4 GB, calculate number of


photos with size 10MB which can be stored in the pen
drive.
SIGN AND MAGNITUDE REPRESENTATION

• UNSIGNED NUMBER : WITH POSITIVE OR NEGATIVE SIGN

EIGHT BIT REPRESENTATION : 2^8= 0 TO 127

EXAMPLE: 11000000 AND 01000011


00000000
SIGNED NUMBER :
EIGHT BIT REPRESENTATION : (2^8-1)
EXAMPLE : 11000000 01000000 10000000
00000000
TWO COMPLEMENT FORM OF NUMBER
REPRESENTATION
• Signed integers representation
One’s complement
• Binary number obtained each bit is individually subtracted from1.
• Each bit converted to its inverse.
• Example: 10001
• One’s complement 11111- 10001= 01110
Two’s complement
The one’s complement plus 1
01110+1 =01111
CONVERTING DENARY POSITIVE NUMBER TO ITS TWO’S
COMPLEMENT

• Step 1: Convert decimal number to binary value


• Step 2: Add a 0 in front of this binary value
CONVERTING DENARY NEGATIVE NUMBER TO ITS TWO’S
COMPLEMENT

• Step 1: Convert decimal number to binary value ignoring the sign


• Step 2: Add a 0 in front of this binary value
• Step 3: Convert this binary value to its two’s complement form.
CONVERTING POSITIVE NUMBER EXPRESSED IN 2’C TO CORRESPONDING DENARY
NUMBER

• Ignore the leading zero


• and convert the remaining bits into its binary using
multiplication method

Example : 011101
CONVERTING NEGATIVE NUMBER EXPRESSED IN 2’C TO CORRESPONDING DENARY
NUMBER

• It can be solved in two ways:


Method 1:
Step 1: Convert to the corresponding positive binary number( by taking 2’c)
Step 2: Find the denary value
Step 3: Add the minus sign.
Method 2: Sum the individual position values but treat the most significant bit as
negative.
METHOD 1
Lets consider two’s complement of binary number 10110001.
Step 1 : Convert to 2’s complement=01001111
Step 2: Now obtain the denary number.
2x1=2
Add 0, 2x2=4
Add 0, 4x2=8
Add 1, 9x2=18
Add 1, 19x2=38
Add 1, 39x2=78
Add 1 = 79
Step 3: add minus sign
the equivalent number is -79
METHOD 2
GIVEN CODE IS: 10110001
-27 26 25 24 23 22 21 20
1 0 1 1 0 0 0 1
=(-27 X1) + (0X 26) + (1X 25) + (1X 24) + (0X 23) + (0X 22) + (0X 21) + (1X20)

=-128 + 0 + 32 + 16 + 0 + 0 + 0 + 1
=-79
TASK
• Convert a negative number expressed in two’s complement
form to get corresponding denary number:
a. 1101011 b. 100101 c. 1101111 d. 1001001
EXAMPLE
• Lets take an example for two’s complement of negative number 5. (TASK 1.02)
Two’s complement (-5)= 1011
Take two’s complement of the binary number again to get the code for
positive number.
So, Two’s complement= 0101 (which is actually positive no, 0+4+0+1=5)
• Take two’s complement for of binary code and show that you get positive code.
a. -7 b. -41(7 bits) c. -6
BINARY ARITHMETIC
BINARY ADDITION BINARY SUBTRACTION

0+0=0 0-0=0
0+1=1 1-0=1
1+0=1 1-1=0
1+1= 0 WITH CARRY OVER 1
0-1= 1 WITH BORROW 1
1+1+1=1 WITH CARRY OVER 1
BINARY SUBTRACTION USING TWO’S
COMPLEMENT

• Using the two’s complement representation, the process of


arithmetic calculation is easy.
• To subtract a number from any other number, we can
convert the number being subtracted to its two’s
complement and then add to the other number.
Subtract 11 from 35. (35-11 represent by byte)

For an example: binary code for 35 = 00100011


binary code for 11= 00001011
Take two’s complement of 11(00001011)= 11110101
Now add the two values, 0 0 1 0 0 0 1 1
+1 1 1 1 0 1 0 1
OVERFLOW 1 0 0 0 1 1 0 0 0=24
TASKS
Perform binary subtraction using two’s complement
a. 26-12 b. 45-31 c. 124-54
BCD(BINARY CODED DECIMAL)

• The binary-coded decimal (BCD) is an encoding for decimal


numbers in which each digit is represented by its own binary
sequence.
• Its main virtue is that it allows easy conversion to decimal digits for
printing or display and faster decimal calculations.
BINARY CODED DECIMAL(BCD)
• In this code each decimal digit is represented by a 4-bit(1 nibble) binary number.
• BCD is a way to express each of the decimal digits with a binary code.
• In the BCD, with four bits we can represent sixteen numbers (0000 to 1111).
• But in BCD code only first ten of these are used (0000 to 1001). The remaining
six code combinations i.e. 1010 to 1111 are invalid in BCD.
ALTERNATIVE BCD REPRESENTATIONS

• If a denary number with more than one digit is to be converted to BCD there has
to be a group of four bits for each denary digit.
• There are, however, two options for BCD:
1. To store one BCD code in one byte leaving 4 bits unused.(unpacked BCD)
2. The other option is packed BCD where two 4-bit codes are stored in one byte.
(packed)
BCD Code for denary number 2408

1 BCD digit per byte (unpacked)

00000010 00000100 00000000 00001000

2 BCD digits per byte(packed)

00100100 00001000
Packed BCD
• A widely used variation of the two-digits-per-byte encoding is called packed BCD (or simply
packed decimal), where numbers are stored with two decimal digits "packed" into one byte each,
and the last digit (or nibble) is used as a sign indicator.
• The preferred sign values are 1100 (hex C) for positive (+) and 1101 (hex D) for negative (−);
other allowed signs are 1010 (A) and 1110 (E) for positive and 1011 (B) for negative.
• Some implementations also provide unsigned BCD values with a sign nibble of 1111 (hex F).

• In packed BCD, the number +127 is represented as the bytes 00010010 01111100 (hex 12 7C),
and −127 as 00010010 01111101 (hex 12 7D).
ADVANTAGES OF BCD CODE

• It is very similar to decimal system.


• Its main virtue is that it allows easy conversion to decimal digits for printing or
display and faster decimal calculations.

• We need to remember binary equivalent of decimal numbers 0 to 9 only.


DISADVANTAGE OF BCD CODE

• The addition and subtraction of BCD have different rules.


• The BCD arithmetic is little more complicated.
• BCD needs more number of bits than binary to represent the decimal number. So
BCD is less efficient than binary.
WHERE ARE BCD CODES USED?
• There are number of applications where BCD can be used.
• The obvious type of application is where denary digits are to be displayed, for
instance on the screen of calculator or in digital time display.
• Lets take an example for BCD addition: (25 + 34)
0010 0101
+0011 0100
0101 1001 =5 9
BCD ADDITION
• ANOTHER EXAMPLE: (24 + 59)
0010 0100
+0 1 0 1 1001
0111 1 1 0 1 =7 13
Here, 13 cannot be represented in BCD, So when we get value more than 9, add
You add 6 to skip the 6
0110(ie;6) on it. The extra bit is added to the next number. remaining "invalid" values
and carry to the next digit
01111101
1 0110
1001 10 0 1 1 =8 3
ASCII
• ASCII stands for American Standard Code for Information Interchange.
• If text is to be stored in a computer, it is necessary to have a coding scheme that
provides a unique binary code for each distinct individual component item of the
text (character code).
• ASCII is the internationally agreed standard.
• The ASCII code associates an integer value for each symbol in the character set,
such as letters, digits, punctuation marks, special characters, and control
characters.
ASCII
• The ASCII table has 128 characters, with values from 0 through 127.
Thus, 7 bits are sufficient to represent a character in ASCII.
• However, most computers typically reserve 1 byte, (8 bits), for an
ASCII character.
• One byte allows a numeric range from 0 through 255 which leaves
room for growth in the size of the character set, or for a sign bit.
ASCII
• Looking at the table, note that the decimal values 0 through 31, and 127,
represent non-printable control characters.
• All other characters can be printed by the computer, i.e. Displayed on the screen
or printed on printers, and are called printable characters.
• All printable characters and many control characters can be input to the
computer by typing the corresponding keys on the keyboard.
• Only a single key is pressed for a printable character; however, control
characters need either special keys on the keyboard or require the ctrl key
pressed together with another key.
• Notice that the character 'A' has the code value of 65, 'B' has the
value 66, and so on. The important feature is the fact that the ASCII
values of letters 'A' through 'Z' are in a contiguous increasing numeric
sequence.
• The values of the lower case letters 'a' through 'z' are also in a
contiguous increasing sequence starting at the code value 97.
• Similarly, the digit symbol characters '0' through '9' are also in an
increasing contiguous sequence starting at the code value 48.
ADVANTAGES OF ASCII CODE

• The codes for numbers and for letters are in sequence in each case so that if 1
is added to the code for 7 the code for 8 is produced.
• The codes for the uppercase letters differ from the codes for the corresponding
lower case letters only in the value of bit 5. This makes the conversion of upper
case to lower case and vice versa easy.
IMAGES
1. Images can be stored in a computer system for displaying
on the screen or for presenting it on paper: created by using
an appropriate drawing package.
2. When an image already exists independently of the
computer system, the image can be captured by using
photography or by scanning.
VECTOR GRAPHICS( FOR GEOMETRICALLY DEFINED
SHAPES
1. An image that is created by a drawing package or a computer aided design (CAD) package to consist of a
number of geometric objects. The outcome is then usually for the image to be stored as a vector graphic file.
2. Vector graphic: a graphic consisting of components defined by geometric formulae and associated properties
such as line color and style.
3. We don’t need to consider how an image of this type is created here rather we need to know how the data is
stored after the image has been created.
4. a. A vector graphics file contains a drawing list.
b.The list contains a command for each object included in the image.
c.Each command has a list of attributes that define the properties of the object.
d.The properties include the basic geometric data such as , for circle, the position of the center and its
radius. The thickness, style of the line, the color of the line and the color that fills the shape.
5.The image is scalable.( the dimensions of the objects are not defined explicitly but instead are defined relative
to an imaginary drawing canvas.)
BITMAPS
• Most images do not consist of geometrically defined shapes so a vector graphic
representation is inappropriate.
• The general purpose approach is to store an image as a bitmap.
• The fundamental concept underlying the creation of a bitmap file is that picture element
(pixel) is the smallest identifiable component of a bitmap image.
• The image is stored as two dimensional matrix of pixels.

• The pixel itself is a very simple construct; it has a position in the matrix and it has a color.
WHAT IS THE DIFFERENCE BETWEEN
BITMAP AND VECTOR IMAGES?
• Bitmap (or raster) images are stored as a series of tiny dots called pixels.
• Each pixel is actually a very small square that is assigned a color, and then arranged in a
pattern to form the image.
• When you zoom in on a bitmap image you can see the individual pixels that make up that
image.
• Bitmap graphics can be edited by erasing or changing the color of individual pixels using a
program such as adobe photoshop.
• Unlike bitmaps, vector images are not based on pixel patterns, but instead use mathematical
formulas to draw lines and curves that can be combined to create an image from geometric
objects such as circles and polygons.
• Vector images are edited by manipulating the lines and curves that make up the image using
a program such as adobe illustrator.
Vector Vs Bitmap
• Vector images have some important advantages over bitmap images.

• Vector images tend to be smaller than bitmap images .


That’s because a bitmap image has to store color information for each individual pixel that forms the image. A vector
image just has to store the mathematical formulas that make up the image, which take up less space.

• Vector images are also more scalable than bitmap images


When a bitmap image is scaled up you begin to see the individual pixels that make up the image. This is most
noticeable in the edges of the image. There are ways of making these jagged edges less noticeable but this often
results in making the image blurry as well. When a vector image is scaled up, the image is redrawn using the
mathematical formula, so the resulting image is just as smooth as the original.
• The three most popular image formats used on the web (png, jpeg, and gif) are bitmap formats. The scalable vector
graphics (SVG) format comes in a distant fourth due to a legacy of poor support for vector graphics in early
browsers. Today however, all major browsers support the SVG (scalable vector graphics) format.
• Bitmap formats are best for images that need to have a wide range of color gradations, such as most photographs.
• Vector formats are better for images that consist of a few areas of solid color. Examples of images that are well
suited for the vector format include logos.
PIXEL
• It is considered to be small rectangle, a small circle or a dot.
• The scheme to represent the color has to be decided
1. Simplest option: 1 bit to represent the color: the pixel is either
black or white.
2. Storage of color using 4 bits: simple greyscale coloring.
3. At least 8 bits: colored imaged.
The number of bits per pixel is referred as color depth.
• Bit depth is best defined as the number of bits used to store each of
the red, green and blue primary colors in the RGB color scheme.
• A color depth of 8 bits per pixel provides 256 different colors.

• A bit depth of 8 bits per primary color provides 256 × 256 × 256 =
16 777 216 different colors
• You can calculate the size of a bitmap graphic knowing the
resolution and the color depth.
RESOLUTION

• The resolution of the image has to be decided:


It is the product of the number of pixels per row times number of
rows.
• the resolution of a stored image and the resolution of the monitor screen
that is used to display the image.
• Both of these have to considered if a screen display is being designed.
EXAMPLE
• You can calculate the size of a bitmap graphic knowing the resolution and the color
depth.
• Consider that a bitmap graphic is needed to fill a laptop screen where the resolution
is 1366 by 768. If we want color depth of 24 then the number of bits we need is:

1366 × 768 × 24 = 25 178 112 bits


= 25 178 112 ÷ 8
= 3 147 264 bytes
= 3 147 264 ÷ 1024
= 3073.5 KiBi bytes (3073.5 KiB)
= 3073.5 ÷ 1024 = approximately 3 MiB
POINTS TO KNOW

• The following are considerations when justifying the use of either a bit map or a
vector graphic for a specific task.
• A vector graphic is chosen if a diagram is needed to be constructed for part of an
architectural, engineering or manufacturing design.
• If a vector graphic file has been created but there is a need to print a copy using a
laser or inkjet printer the file has first to be converted to a bitmap
. • A digital camera automatically produces a bitmap
. • A bitmap file is the choice for insertion of an image into a document, publication
or web page
FILE HEADER

• A bitmap file has to store the pixel data that defines the graphic, but the file must
also have a file header that contains information on how the graphic has been
constructed.

• Because of this, the bitmap file size is larger than the size of the graphic alone.
• At the very least the header will define the color depth or bit depth and the
resolution.
• Four binary digits count up to 15 (1111) but in BCD we only use the representations up
to 9 (1001). The difference between 15 and 9 is 6. If you want 9+1 to produce 10, which
is 1 0000, you have to add 6 to make 1010 wrap to 1 0000.
• If you're adding minutes, you similarly add 40 to a time which exceeds 59 minutes.
Example: 45 minutes plus 35 minutes is 80 minutes. Correction, add 40 to make 120.
Now insert a colon: 1:20. One hour, twenty minutes. 40 is the difference between 100
and 1:00.
SOUND REPRESENTATION

• Sound is transmitted through gases, plasma, and liquids


as longitudinal waves, also called compression waves.
• It requires a medium to propagate. Through solids, however, it
can be transmitted as both longitudinal waves and transverse
waves.
SOUND REPRESENTATION
Pre-understanding
• Sound is transmitted through gases, plasma, and liquids as longitudinal waves, also
called compression waves.
• It requires a medium to propagate.
• Through solids, however, it can be transmitted as both longitudinal waves and transverse waves.
• Transverse waves are always characterized by particle motion being perpendicular to wave motion.
• A longitudinal wave is a wave in which particles of the medium move in a direction parallel to the
direction that the wave moves
HOW DO WE HEAR SOUND?
• Sound is an oscillation of pressure transmitted through a solid, liquid, or gas (there is no sound in
outer space as space is a vacuum and there is no solid, liquid or gas to transmit sound through!).
• A speaker works by moving its center cone in and out, this causes the air particles to bunch
together forming waves.
• These waves spread out from the speaker travelling at 340 m / s. (differs according to medium)
• If your ear is in the way, then the waves of sound particles will collide with your ear drum,
vibrating it and sending a message to your brain. This is how you hear
FACTS ABOUT SOUND
• Natural sound consists of variations in pressure which are detected by the human
ear.
• Humans can detect sounds in a frequency range from about 20 Hz to 20 KHz.
• A typical sound contains a large number of individual waves each with a defined
frequency. The result is a wave form in which the amplitude of the sound varies in
a continuous but irregular pattern.
• When you hear different volumes and pitches of sound all that is happening is that
each sound wave varies in energy for the volume (larger energy waves, the louder
the sound), or distance between sound waves which adjusts the pitch, (smaller
distances between waves leads to higher pitched sound)
High pitch sound=high frequency
Sound consists of air vibration
High vibration rate=high frequency
The unit of 1 cycle per second= 1 hertz
REPRESENTING SOUND

• Analogue physical quantity: speech, music varies with time.


• Sound waves in nature are continuous, this means they have
an almost infinite amount of detail that you
• Could store for even the shortest sound. This makes them very
difficult to record perfectly, as computers can only store
discrete data, data that has a limited number of data points
• Samples have to taken to be quantized to the nearest binary
code in the digital representation
( As speech or music varies rapidly)
SAMPLING RATE

• To create digital music that sounds close to the real thing you need to look at the analogue
sound waves and try to represent them digitally.
• This requires you to try to replicate the analogue (and Continuous) waves as discrete
values.
• The first step in doing this is deciding how often you should sample the sound wave, if you
do it too little, the sample stored on a computer will sound very different from the one
being recorded.
• Sample too often and sound stored will resemble that being recorded. But having to store
each of the samples means you'll get very large file sizes. To decide how often you are
Sampling Theorem (NYQUIST'S THEOREM )

How often sound must be sampled?

If the frequencies in sound range from 0 to B Hz then,


the sound must be sampled at a rate greater than 2B
samples per second.

Sampling rate> 2 x highest frequency


SOUND ENCODER
If we need to store sound or it has to be transmitted electronically the original sound
signal has to be converted to binary code by a sound encoder.
A sound encoder has two components
1. Band limiting filter : to remove high frequency components.
The ear would not be able to detect these and they could cause problems for the coding if
not removed.
2. Analog to digital converter (ADC)
ANALOG TO DIGITAL CONVERSION

1. The signal is sampled


2. The sampled signal is quantized.
3. The quantized signal is digitally coded.

• The red line represents the wave to be


sampled.
• The blue lines indicate the sampling times
• The amplitude cannot measured exactly rather
approximated by closet horizontal line
• Sample 1, 4 accurate
• Samples 5, 6 will not be accurate.
HOW IT WORKS: RESOLUTION

• The value of each sampled point will be stored on a fixed-length variable.

• If this variable uses eight bits, this means it can hold values from 0 to 255 (2^8 = 256).

• If this variable uses 16 bits, this means it can hold values from 0 to 65,535 (2^16 =
65,536). And so on.
FILE SIZES

• Bit rate - the number of bits required to store 1 second of sound


bit rate= sampling rate* sample resolution
• To work out the size of a sound sample requires the following
equation:
File size = sample rate * sample resolution * length of sound
• This is the same as saying:
File size = bit rate * length of sound
EXAMPLE

• Sound file sizes if you wanted to record a 30 second voice message on your mobile phone you would use the
following:
Sample rate = 8,000hz
sample resolution = 16 bit
length of sound = 30 seconds
• Therefore the total file size would be:
8,000 * 16 * 30 = 3 840 000 bits = 480 000 bytes
COMPRESSION TECHNIQUE

• Lossless Compression
• Lossy Compression
LOSSY COMPRESSION

• Lossy compression removes some of a file’s original data in order to reduce the file size.
• This might mean reducing the numbers of colors in an image or reducing the number of
samples in a sound file.
• This can result in a small loss of quality of an image or sound file.
• JPEG for image and MP3 for sound.
• Once a file has been compressed using lossy compression, the discarded data cannot be
retrieved again
• Lossy compression reduces bits by identifying unnecessary information and removing it. The process
of reducing the size of a data file is referred to as data compression.
• Image compression may be lossy or lossless.
• Lossless compression is preferred for archival purposes and often for medical imaging, technical
drawings, clip art, or comics.
• If a file contains text, then compression must be lossless because any loss of information would lead
to errors in the text. .
• Lossy methods are especially suitable for natural images such as photographs in applications where
minor (sometimes imperceptible) loss of fidelity is acceptable to achieve a substantial reduction in bit
rate.
• The lossy compression that produces imperceptible differences may be called visually lossless.
• Lossy compression methods, especially when used at low bit rates, introduce compression artifacts
• Lossy eliminate less audible or meaningful sounds, thereby reducing the space required to store or
transmit them.
LOSS LESS COMPRESSION

• Lossless compression is coding techniques that allow subsequent decoding to recreate


exactly the original file where the file size is reduced but no information is lost.
• The process can be reversed to re-create the original file
• There are various algorithms for doing this, usually by looking for patterns in the data that
are repeated.
• Zip files are an example of lossless compression.
• The space savings of lossless compression are not as good as they are with lossy
compression.
RUN LENGTH ENCODING

• The idea is that compression converts sequences of the same byte value into a code
that defines the byte value and the number of times it is repeated (the count).
• For example, the sequence of the same four bytes:
01100110 01100110 01100110 01100110
could be replaced by:
00000100 01100110
Which says that there is a run of four of the bytes.
HUFFMAN CODING

• Instead of having each character coded in one byte, the text is analyzed to find the most often used
characters.
• These are then given shorter codes.
• The Huffman Code compression technique is used to create variable-length coding, which uses a
varied amount of bits for each letter or symbol.
• Huffman coding can also be used for compressing a sound file. This is effective because some
values for the amplitude occur far more often than others do.
• If a vector graphic file needs to be compressed it is best converted to a scalable vector graphics
format. This uses a markup language description of the image which is suitable for lossless
compression
DISCUSSION POINT

• Graphic files can be stored in a number of formats. For


example, JPEG, GIF, PNG and TIFF are just a few of the
possibilities. What compression techniques, if any, do these
use?

You might also like