data representation int 2 computing unit 1 – computer systems st kentigern’s academy

26
Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Upload: julie-simpson

Post on 29-Dec-2015

220 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Data Representation

Int 2 Computing Unit 1 – Computer Systems

St Kentigern’s Academy

Page 2: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Data Representation Binary Code

Measuring storage

Representing numbers

Representing text

Representing graphics

Page 3: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Binary Codes What is binary anyway?

binary means "two state“; binary codes are made from two

symbols only; 1 and 0; electronic computers have many

circuits that switch ON and OFF; if electricity is sent along a wire it is

represented by a 1 and if electricity is not sent along a wire it is represented by a 0.

Page 4: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Binary Codes why do computers use binary

(rather then decimal)?

binary values 1 and 0 match exactly to circuits switched ON and OFF;

circuits that work with only two symbols are very simple, that makes them fast at working and cheaper to make;

the rules for adding and calculating binary are few, again that makes the ALU simple and cheap to make.

Page 5: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Representing Numbers Advantages of using Binary

Binary is a simple two-state system (1 or 0) which is ideal when representing a two-state system of “power on/power off”

A degraded signal can still be detected as representing 1

There are only a few rules of addition, making calculations simpler

Page 6: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Measuring Storage

Abbr Term Meaning

b bit a single binary digit, 0 or 1

B byte 8 bits

Kb kilobyte 1024 bytes

Mb megabyte 1024 kb

Gb gigabyte 1024 mb

Tb terabyte 1024 gb

Page 7: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Converting between units

To change: Bits to bytes, divide by 8 Bytes to bits, multiply by 8 Bytes to kilobytes, divide by 1024 Kilobytes to bytes, multiply by 1024 Kilobytes to megabytes, divide by 1024 Megabytes to kilobytes, multiply by 1024 Megabytes to gigabytes, divide by 1024 Gigabytes to megabytes, multiply by 1024 Gigabytes to terabytes, divide by 1024 Terabytes to gigabytes, multiply by 1024

Page 8: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Measuring Storage How to remember storage:

Bit, Big Byte, Bottoms Kilobyte, Kill Megabyte, Many Gigabyte, Grey Terabyte Toads

Page 9: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Measuring Storage Backing Storage Capacity

Floppy Disk – 1.44mb CD – 750mb DVD – 4.6gb Hard Drive – 180gb Tape Drive – 180gb

Memory Capacity RAM – 2gb

Page 10: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Representing Numbers We use decimal to count –

Th,H,T,U We start with 1 and multiply it by 10 to get

Ten’s; we multiply this by 10 to get Hundreds and so on…

HTh TTh Th H T U

0 0 1 2 3 1 = 1231

0 1 0 2 2 0 =10220

Page 11: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Representing Numbers Computers don’t use Base 10 they

use base 2. So we start with 1 and multiply it by 2 to

get 2, we multiply this by 2 to get 4 and so on…

128 64 32 16 8 4 2 U

0 0 1 0 1 0 1 1 = 43

0 1 0 0 1 1 1 0 =79

Page 12: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Converting decimal to binary

If we have a decimal number, e.g. 28, we look to see what numbers in the headings make up our decimal number when added.

So 16 + 8 + 4 = 28 We put a binary 1 under the 16, 8 and 4,

and a binary 0 under the other headings.

128 64 32 16 8 4 2 U

0 0 0 1 1 1 0 0 = 28

0 1 0 0 1 0 0 0 = 72

Page 13: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Converting Binary to decimal

If we have a binary number, e.g. 00110011, we put the numbers under the corresponding headings.

Where ever there is a 1 we add up the headings.

So 32 + 16 + 2 + 1 = 51

128 64 32 16 8 4 2 U

0 0 1 1 0 0 1 1 = 51

0 1 0 0 1 0 4 0 = 74

Page 14: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Representing Numbers A 4-bit system has 4 headings :

128

64 32 16 8 4 2 U

1 1 1 1 1 1 1 1 = 255

8 4 2 U

1 1 1 1 = 15

An 8-bit system has 8 headings :

Page 15: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

What do the Headings Mean? When we talk about the bit size we mean the number

of bits assigned to represent data.

If we have 2 bits, we have 2 headings which gives us 22 = 4 different binary patterns. If we have 3 bits, we have 3 headings which gives us 23 = 8 different binary patterns:

2 U 4 2 U0 0 0 0 00 1 0 0 11 0 0 1 01 1 0 1 1

1 0 01 0 11 1 01 1 1

Page 16: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Binary/Decimal Conversion

Convert the following to binary:

23 67 255 257

Convert the following to decimal:

0011 1111 0110 1010 1111 0011 1011 1111

• • • Remember your headings • • •

0001 01110100 0111

1111 111

0001 0000 0001

63

106243191

Page 17: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Real Numbers Very large and very small numbers would take up too

much space in memory so a different technique called floating point representation is used to store these numbers

Real number are numbers with a decimal point and are represented using floating point.

The number contains a mantissa and exponent.

The mantissa is the number. The exponent is where the point is placed.

The rule is to place the binary point in front of the digits and to count the number of places that it has been move.

Page 18: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Real Numbers

Example – What do we do with a decimal point?

12.4 = .124 *102

= 01111100*20010

01111100 is called the mantissa0010 is called the exponent

And both of these numbers are stored in memory.

Page 19: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

AscII – Text representation

American Standard Code for Information Interchange: The ASCII system was introduced so that all

computers use the same binary code to represent the computers character set – all the letters, numbers and symbols that can be displayed by the computer.

ASCII gives each character a unique number which can easily be changed into binary:

A = 65 = 0100 0001

The ASCII system standardises computers, therefore making text files compatible with a wider range of computer systems.

Page 20: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

ASCII ASCII is a 7-bit code which provides 27 = 128 code

values. But as we study 8-bit systems at Int 2 we put a 0 in front of the ASCII code.

This allows 96 characters and 32 control characters – these characters do not print anything on the screen, they control certain operations of the computer system , e.g. cursor keys. Here is part of the ASCII table:

Character ASCII code Decimal

ABZa2

Beep&

0100 0001010000100101101001100001001100100000011100100110

65669097507

38

Page 21: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Question time

1. What is a character set?

2. What is a control character?

3. What does ASCII stand for?

4. How many characters can ASCII represent?

5. Explain how real numbers are represented in binary.

Page 22: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Representing graphics Computers store graphical images in

memory, on backing storage devices and display them on the monitor as bit maps.

A picture cell or pixel is the most basic component of any computer graphic. Every computer graphic is made up of a grid of

pixels.

The computer represents the image in memory as a file of 0s and 1s White pixels are represented by a 0 and black

pixels by a 1 The file is known as a bit map

Page 23: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Representing graphics

0 0 1 1 1 1 0 0

0 1 0 0 0 0 1 0

0 1 0 0 0 0 1 0

1 0 1 0 0 1 0 1

0 1 0 0 0 0 1 0

0 1 0 1 1 0 1 0

0 0 1 0 0 1 0 0

0 0 0 1 1 0 0 0

There is a one-to-one relationship between the pixels There is a one-to-one relationship between the pixels and the bit patternand the bit pattern

Page 24: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Graphics - Resolution The quality of a graphical image is directly

related to the number of pixels used to produce it.

A good quality image will have many small pixels, e.g. a photo

A poor quality image will have few large pixels, e.g. teletext

The density of pixels is called the resolution of the image. This is measured in dots per inch (dpi).

The higher the resolution, the more pixels, the better the quality of the graphic, but the more storage required to store the graphic.

Page 25: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Graphic Calculations In a black and white image each pixel is represented

by 1 bit.

We want to calculate the storage requirements for an image that has a dpi of 1200dpi and has a length of 5 inches and a breadth of 4 inches.

Number of pixels in length = 1200 x 5 = 6000 pixelsNumber of pixels in breadth = 1200 x 4 = 4800 pixels

Total no of pixels = 6000 x 4800= 28,800,000 pixels

1 pixel needs 1 bit of data storage = 28,800,000 bits/8 to get bytes =

3,600,000 bytes/1024 to get kb = 3515.625 Kb/1024 to get mb = 3.46 Mb

Page 26: Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy

Question time

1. What does the term resolution mean?

2. Describe how a graphic is represented in binary.

3. Calculate the following graphics storage requirements:

1. 300dpi, 4” by 5”2. 600dpi, 5” by 7”3. 578pixels by 1200pixels