20
Marr College Higher Computing Slide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Embed Size (px)

Citation preview

Page 1: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 1

Higher Computing: COMPUTER SYSTEMS

Part 1: Data Representation – 6 hours

Page 2: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 2

Data

Rep

resen

tati

on

Positive 8-bit binary numbers

Convert binary to decimal

1. Write place headings

2. Write binary number

3. Total headings where 1 present (ignore 0s)

128 64 32 16 8 4 2 1

0 1 0 1 1 1 0 1

=> 64 + 16 + 8 + 4 + 1 = 93

Binary 0101 1101 is Decimal 93

Place headings

Binary number

INT 2

Page 3: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 3

Data

Rep

resen

tati

on

Advantages of Binary

Advantages

1 Binary 0 and 1 can be simply used to represent OFF or ON

2 A “degraded” signal can still be detected as representing 1

3 Binary has only 5 rules for addition making calculations simpler.

INT 2

Page 4: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 4

Data

Rep

resen

tati

on

Range up to and including 32-bits

The range of positive integer numbers in binary up to 32 bits are detailed in the table below:

Unit Range

1 Bit 0 to 21 – 1 (0 to 1)

8 bits (1 Byte) 0 to 28 – 1 (0 to 255)

16 bits (2 bytes) 0 to 216 – 1 (0 to 65,535)

24 bits (3 bytes) 0 to 224 – 1 (0 to 16, 777, 215)

32 bits (4 bytes) 0 to 232 – 1 (0 to 4,294,967,295)

These measurements are used to determine the lower and upper limits of the range numbers possible with a given amount of bits or bytes.

Page 5: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 5

Data

Rep

resen

tati

on

Negative numbers and two’s complement

Two’s complement

1 State the positive binary number

2 Invert 0s and 1s

3 Add 1

128 64 32 16 8 4 2 1

0 0 0 0 1 0 0 1

1 1 1 1 0 1 1 0

0 0 0 0 0 0 0 1

1 1 1 1 0 1 1 1

=> (-128 )+ 64 + 32 + 16 + 4 + 2 + 1 = - 9

Rules of Binary Addition

0 + 0 = 0 1 + 1 = 0 carry 1

0 + 1 = 1 1 + 1 + 1 = 1 carry 1

1 + 0 = 1

Example: Represent -9 using two’s complement method.

= +9

= Inversion

= Add binary 1

= Answer!

Indicates sign 0 = +, 1 = -

Page 6: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 6

Data

Rep

resen

tati

on

Floating point representation

Here is a fractional binary number…

1 1 0 1 . 0 0 1 1 0 1 1 1 0 0 1 0

Rule: Move the point in front of the digits.

Binary point

So the same number could be written as..

. 1 1 0 1 0 0 1 1 0 1 1 1 0 0 1 0 x 2 0000 0100

Mantissa Exponent

INT 2

Page 7: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 7

Data

Rep

resen

tati

on

Floating point representation

And the same number would be stored in memory as…

Byte 1 Byte 2 Byte 3

1 1 0 1 0 0 1 1 0 1 1 1 0 0 1 0 0 0 0 0 0 1 0 0

Therefore…

The mantissa stores the actual digits of the number. Increasing the number of bits increases the precision (accuracy) of the number.

The exponent stores the number of places the point has been moved. Increasing the number of bits increases the range of numbers that can be stored.

Mantissa Exponent

Page 8: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 8

Data

Rep

resen

tati

on

Storage Capacity

Memory is organised into groups of bytes and large files sizes are represented as powers of 2.

Unit Bytes

1 Bit 0,1

1 Byte 8 bits

1 Kilobyte (Kb) 210 = 1024 bytes

1 Megabyte (Mb) 220 = 1,048,576 bytes (1024 Kb)

1 Gigabyte (Gb) 230 = 1,073,741,824 bytes (1024 Mb)

1 Terabyte (Tb) 240 = 1,099,511,627,776 bytes (1024 Gb)

These measurements are used in memory (e.g. RAM) and backing storage (e.g. hard disc, DVD etc.)

INT 2

Page 9: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 9

Data

Rep

resen

tati

on

ASCII - American Standard Code for Information Interchange

To represent text a unique 7 or 8 bit binary code is used for each character on the keyboard.

Character ASCII code Decimal

A 0100 0001 65

B 0100 0010 66

Z 0101 1010 90

a 0110 0001 97

2 0011 0010 50

Beep 0000 0111 7

& 0010 0110 38

Examples of Standard ASCII

Note the leftmost bit is always 0, hence only 7-bits used in Standard ASCII.

The ‘eighth bit’ increases the range of possible characters to 256 and gives Extended ASCII.

A character set is the complete set of characters that are on the keyboard e.g. 1 2 3, a b c, ! ” £, and control characters.

A control character is non-printable e.g. RETURN, TAB, ESCAPE, SPACE etc. They are the first 32 characters in ASCII.

ASCII enables the transfer data from one computer or software package to another e.g. email. It is the simplest form of text with no formatting.

INT 2

Page 10: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 10

Data

Rep

resen

tati

on

Unicode

Unicode is a 16-bit code (2 bytes) that supports 65,536 characters

Snapshot of German keyboard

Advantages

• A code for every character based alphabet in the world

• Has codes for Chinese, Arabic etc.

• Covers all punctuation marks and control characters

Page 11: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 11

Data

Rep

resen

tati

on

Bitmapped graphics

Any graphic is made up from a series of pixels (picture elements).

Each pixel is an individual dot on the screen.

The BIT MAP of the imagePixel pattern using 8 x 8 grid

In a monochrome graphic, each pixel is represented by either

0 - white OR 1 - black

INT 2

Page 12: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 12

Data

Rep

resen

tati

on

Resolution

The quality of the image depends on the number of pixels

More pixels means higher resolution and clearer, sharper image.

Pixel pattern using 8 x 8 grid Pixel pattern using 16 x 16 grid

High resolution = many small pixels, larger file size

Low resolution = larger pixels, smaller file size

INT 2

Page 13: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 13

Data

Rep

resen

tati

on

Storage

Each pixel requires 1 bit of storage.

So, the more pixels used, the larger the file size.

8 x 8 = 64 bits

64 bits / 8 = 8 bytes

File size of this graphic is 8 bytes

Example 1

16 x 16 = 256 bits

256 bits / 8 = 32 bytes

File size of this graphic is 32 bytes

Example 2

INT 2

Page 14: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 14

Data

Rep

resen

tati

on

Bit-depth and no. of colours up to 24-bits (true colour)

Bitmap graphics are made up of pixels (dots) and each dot is stored as bits or bytes in memory.

Bit-depth is the number of bits used to represent shades of colours of a pixel.

Colours Bits Bytes

2 1 1/8

16 4 1/2

256 8 1

65, 536 16 2

16, 777, 216 24 3

The more bits per pixel the more colours can be used - but file size will increase.

Page 15: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 15

Data

Rep

resen

tati

on

Dots per inch (dpi)

Dpi is a measure of how many pixels (dots) are in an square inch.

Printers and scanners state resolution in dpi.

Example

The dimensions of an image are 4” x 6”, the resolution is 300 dpi and it is black and white. Calculate the file size.

Formula:

Pixels / bits = length x breadth x dpi2

4 x 6 x 300 x 300 = 2,160,000 bits

=> 2160000 / 8 = 270,000 bytes

=> 270,000 = 263.7 kilobytes

File size of this graphic is 263.7 bytes

Page 16: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 16

Data

Rep

resen

tati

on

Bitmapped graphics

Advantages

Individual pixels can be edited

Complexity of image does not affect file size

Can be compressed to JPEG, GIF or TIFF to reduce file size

Disadvantages

× Large file size e.g. 3 bytes per pixel

× Individual objects cannot be edited

× Resolution dependent: low resolution = low quality

× Image ‘pixellated’ when resized bigger

Pixellated bitmap

Page 17: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 17

Data

Rep

resen

tati

on

Need for compression of bitmaps

Bitmapped graphics often have a large file size.

So...

A 1024 x 768 24-bit colour graphic has a file size of 2.25 Megabytes.

An image of this size would be slow to transmit across a network or slow to download from the Internet....

Bitmaps can be compressed using compression algorithms into JPEG or GIF to reduce file size and enable faster transfer / download across networks.

Page 18: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 18

Data

Rep

resen

tati

on

Need for compression of bitmaps

JPEG (Joint Photographics Expert Group)

Lossy compression algorithm where some pixel data is removed, but retains 24-bit colour and minimal loss of quality to human eye – ideal for photographs.

Page 19: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 19

Data

Rep

resen

tati

on

Need for compression of bitmaps

GIF (Graphics Interchange Format)

Lossless compression algorithm where colour depth is reduced to 8-bit resulting in 256 colours – ideal for clip art etc but not for photographs.

Page 20: Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours

Marr College Higher Computing Slide 20

Data

Rep

resen

tati

on

Vectored graphics

Vectors are stored as a description of the objects that make up the graphic e.g. start x, start y, line thickness, fill colour etc.

Advantages

Individual objects can be edited

Objects can be grouped and manipulated as one

Are resolution independent i.e. same quality regardless of resolution

Do not lose quality when resized

Small file size as values not stored for every pixel

Disadvantages

× Cannot be edited at pixel level

× File size can be large if many objects / layers