[1] data representation

Post on 05-Feb-2015

27.128 Views

Category:

Education

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

Unit 1 Data Representation from Computer Systems Unit of Higher Computing

TRANSCRIPT

Data RepresentationRepresent!

How information is stored in a Computer

SystemWith our resident

Binary enthusiast …Brian

• A computer is a two state machine (using only 1’s and 0’s to represent digits ‘on’ and ‘off’

• Represented using voltage (1 – 5 volts is ON! 0 volts … surprise OFF!)

• Binary System 1’s and 0’s• To + - * / fewer rules need to be built into

processor• Drop in voltage - NO EFFECT• Easy to represent two stages in storage

devices (presence of pits on a CD-ROM)

• Use 1’s and 0’s to represent decimal numbers

• A BIT (1 OR 0) is the smallest unit of memory in a computer• 1 bit – 1 or 0 (two different numbers)• 2 bits – 00, 01, 10, 11 (four numbers)• 3 bits – 000, 001, 010, 011, 100, 101, 110, 111 – (8 different numbers)

Are you getting it yet?

• How many different numbers can you represent with?– 4 bits?– 5 bits?– 6 bits?– 8 bits?

• Can easily work it out by …• Number of bits ^ 2

• Taking an example using 8 bits• 256 individual combinations we can make

• 128 64 32 16 8 4 2 1

0 0 0 0 0 0 0 0• Lowest number we can represent

1 1 1 1 1 1 1 1

• Highest number we can represent

• We simply add up the numbers with a 1• 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1

• We want to represent the number 83 in binary• (there’s a couple of ways of working it out)• 128 64 32 16 8 4 2 1 0 (coz 128 don’t fit!) 1 (64 fits, leaves 19)

0 1 (leaves 3) 0 0 Gives us 1 (1 left) 10 1 0 1 0 0 1 1

Ok idiots, give this a go

Convert these from binary to decimal

• 0110 0111• 1110 0011• 0101 0110• 1010 1100

Convert these decimals to binary

• 255• 84• 172• 4

• 128 64 32 16 8 4 2 1

Challenge – 12 bits

Convert these from binary to decimal

• 1001 0110 0111• 0101 1110 0011• 1011 0101 0110• 1101 1010 1100

• 128 64 32 16 8 4 2 1

Right, so that’s easy

Not great, it doesn’t let us represent• Negative Numbers• Fractions of numbers

• Two’s Compliment• Floating Point Representation

Two’s Compliment

Allows us to represent negative numbers• Need a way of recognising if a number is

negative• Two’s Compliment does thus• Take positive binary number 0000 1010 +10• Invert all bits 1111 0101 • ADD 1 ( 1 + 1 = 0, carry over) 1111 0110 -

10• Anyone work out how you know if it’s a

negative number?

Remember!

To check which number representation we are using! If a question doesn’t tell you choose one yourself and write it down!

Convert to two’s compliment representation

• -9• -45• -187• -283

The good thing!

When we are trying to check what a number is in decimal we just repeat the process! (that’s why two’s compliment is so good)

What are these numbers in decimal?• 1000 1101• 1111 0110• 1010 1010• 1100 0011

More good bits

We used to use a signed bit to represent a negative number

• This reduce the number of bits available to represent the number

• This would have reduced the range of numbers which could be represented

• Computer Arithmetic was “Pure Mental”

• 23.75 = 0.2375 * 10 ^ 2• 2375 – the mantissa• 2 – the exponent• The same thing in binary• Mantissa gives the number to be

represented• The exponent gives how many places to

“float” the decimal point

Real Numbers

Number 13.758 4 2 1 0.5 0.25 0.125 0.0625 1 1 0 1 1 1 0 0Mantissa = 1101.1100Exponent (need to move 4 decimal places)8 4 2 10 1 0 0 Exponent = 0 1 0 01101 1100 0100 (all we need)

Increasing the M and the E

Increasing the mantissaGiving more bits to represent a number

would increase the precision

Think of a tape measure(if there are more wee bits marking the

distances you will get a more precise measurement)

Increasing the M and the E

Increasing the exponentThis means that the range of the

numbers is increased

10 * small exponent = small number10 * big exponent (more bits) = bigger

number Worksheet 1

Questions and Reading

From the Walsh Book Read

Pages – 2 to 9

Questions (on page 20)1 2 3 4 5 6 7 8 9

Worksheet 1

Data RepresentationHow text is

represented/sent in a computer system

ASCII CodeUNICODE

Memory Sizes

• A byte is space which is used to store a character ( 8 bits )

• All the characters which can be represented are known as the character set

• Each character to display is given a different code

• ASCII is the most popular form• American Standard Code for Information

Interchange

What does it all mean?•What’s in a bit?

•A 1 or a 0How should you remember

it?•Kinder Bueno

•8 wee bits or one big Byte!

Memory Sizes

• Reminder

•Big•Boys•Kicked•My•Granny•Twice

Memory Sizes

•Bit <- smallest•Byte•Kilobyte•Megabyte•Gigabyte•Terabyte <- biggest

• A bit is the smallest unit of memory• There are 8 bits in a byte• There are 1024 bytes in a kilobyte• There are 1024 Kb in a Megabyte• There are 1024 Mb in a Gigabyte• There are 1024 Gb in a Terabyte

Calculating Memory Sizes

We don’t say our broadband speed is33 million bits per second4 Megabytes

We don’t say our computer has687194767360 bits of

memory80 Gigabytes

Calculating the correct sizes is a wee bit fidgety but you get used to it

Calculating Memory Sizes

bits / 8bytes / 1024kilobytes / 1024megabytes /

1024gigabytes / 1024terabytes

TAKE A NOTE

Terabytes * 1024Gigabytes * 1024Megabytes *

1024Kilobytes * 1024Bytes * 8bits

TAKE A NOTEWorksheet 3

ASCII Code

ASCII is a 7 bit code which allows 128 characters

Extended ASCII allows 8 bits or 256 characters

Used to represent text although some characters don’t print

0 – 31 are what is known as control characters

Carriage Return, Tab, Clear Screen for example

UNICODE

What about the CODES that ASCII cannot represent? The Japanese for example

UNICODE is a 16 bit code which is used to represent a lot more characters

ASCII uses less memory (7 bits)UNICODE capable of representing a lot

more characters

ASCII Code

65 in decimal = A66 = B67 = C and so on and so forth

We can code messages and understand what they say etc

I intercepted a nasty text from Mr Arthur to Mr McGowan help me out a bit

Have a bash at working out this messageWorksheet 2

Data RepresentationGraphics

How are Graphics stored in a Computer

SystemCalculating memory

requirements

• Graphics are made up of tiny dots called PIXELS each requiring one bit

• Picture Elements 49 bits memory. WHY?

Resolution

A screen display of 800 x 600 is smaller is resolution

1024 x 768 is higher resolutionTwo types of Graphic

Bit mapped Vector

Resolution

A screen display of 800 x 600 is smaller is resolution

1024 x 768 is higher resolutionTwo types of Graphic

Bit mapped VectorThese store the graphics in different

ways

Bit Mapped

Think about PaintWhen you draw a shape on top of

another it rubs out anything on the bottom

It has a fixed resolution (which means your image is rubbish when printed!)

You can zoom in and edit individual pixels

It saves the full screen – even if there’s nothing on there!

Vector Graphics

Keeps shapes as separate objects Saves attributes of objects rather than all

pixels – less memory requirementsResolution Independence – prints at the

full resolution available on printerCan edit all the individual objects which

make up the graphic, but not the individual pixels

Backing Storage Requirements

This image of screech measures 2 inches by 2 inches.

It has a resolution of 80 dpi using 256 colours

Memory Required

Total Pixels

(2 * 80) * (2 * 80) = 25, 600

Each pixel could be one of 256 different colours

256 requires 8 bits

25,600 * 8 = 204, 800 bits

204, 800 = 25,600 bytes or 25 kilobytes

Your Turn

This idiots picture measures 3 inches by 2 inches

It has a resolution of 150 dots per inch.

It uses TRUE COLOUR which uses 24 bits per pixel

Worksheet 4

Data RepresentationThe need for Compression

Different methods of Compression

Data Compression

Compression simply means reducing the size of a file in order to save some space

Two different types

Lossy

Lossless

Lossless Compression

Means that none of the original data is lost

Counting repeating pixels is one method

This means you can save– Store what colour pixel is– How many are repeated in a row– Saves a lot of memory

Lossy Compression

Means you sacrifice some data to reduce the file size

• Using complex mathematical coding• Ditching stuff our eyes cant see• Can reduce size more than lossless• But, only if it doesn’t make the file

useless

Worksheet 5

Advantages of Compression

Bit maps use up a lot of backing storage

- Compression saves a lot of it

- The less space it takes up the less time it takes to transfer it in an email etc

- Takes less time to load up in a web browser

Disadvantages of Compression

If Lossy compression is used then detail may be lost from the images

Can alter the images introducing things that weren’t there

Take a lot of time to compress a very large image

Repeated compression can alter and affect the image

And here it ends

That’s everything in Section 1: Data Representation

What you need to do now:Read Scholar for more in depth

informationRead Walsh for the samePractice loads of questions (Walsh Book)Study for end of section test

top related