Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Representation The storage of Text Numbers Graphics.

Similar presentations


Presentation on theme: "Data Representation The storage of Text Numbers Graphics."— Presentation transcript:

1 Data Representation The storage of Text Numbers Graphics

2 As everything in binary is to do with powers of 2, we don’t use thousands, millions, billions etc. 1 bit (binary digit) = 0 or 1 (2 3 ) 8 bits = 1 byte (2 10 ) 1024 bytes = 1 Kilobyte (2 20 ) 1024 Kb = 1 Megabyte (2 30 ) 1024 Mb = 1 Gigabyte (2 40 ) 1024 Gb = 1 Terabyte

3 Data Representation ASCII is a 7 bit code giving a unique code for 128 characters. The first 32 are CONTROL CODES which make something happen. The rest are alphanumeric characters on the keyboard. As computers use 8 bits as a minimum, this allows an extended ASCII set to include symbols like square root, some foreign letters etc.

4 Data Representation Even with 8 bits for ASCII there are only 256 possibilities, not nearly enough to code alphabets from other languages UNICODE solves this problem. Unicode uses 16 bits for each character giving 65 536 different codes. This proves sufficient to code all the main alphabets of the world.

5 Data Representation In base 2 binary, the headings are powers of two Headings:….8421 Number 1 1 10 Giving 1 eight 1 four 1 two 0 unitsmaking 14 in decimal

6 To change any binary number to decimal (denary): Put the headings 2 n …. 2 5 2 4 2 3 2 2 2 1 2 0 above the number. Add up the headings where there is a one. Example: 1100011 6432168421 1 1 00011 64 + 32 + 2 + 1 = 99 Data Representation

7 To change any decimal number to binary you divide repeatedly by 2. The remainders become the binary number. Example 57 2 | 57 2 | 28 R 1 2 | 14 R 0 2 | 7 R 0 2 | 3 R 1 2 | 1 R 1 0 R 1 Data Representation = 1 1 1 0 0 1

8 However, you can more easily work it out from the headings E.g. 46 This needs a 32 an 8 a 4 and a 2 32168421 1 0 1110 Data Representation

9 In two’s complement, you represent a negative by: Write its positive value in binary Flip each bit (1  0, 0  1) Add 1 Example: -18 using 8 bit numbers. 18 = 00010010 Flip11101101 Add 111101110

10 How do you find the value of a two’s complement number? Flip and add 1 to get the value. (i.e. do the 2’s complement again) Eg 11001011 This is -ve because it begins with a 1 Flip : 00110100 Add 1 : 00110101 = 53, so the original number was –53. Data Representation

11 In storing numbers the computer always sets aside the same amount of storage locations in RAM. It doesn’t matter if the number is 3 or 5 billion. Let’s say it just sets aside 1 byte for integers. 8 bits can hold 2 8 = 256 different values With 2 bytes for each integer: 16 bits can hold 2 16 =65 536 different values.

12 Data Representation Now if 8 bits can hold 2 8 = 256 different values The RANGE is 0 to 255 With 2 bytes for each integer: 16 bits can hold 2 16 =65 536 different values. The RANGE is 0 to 65 535

13 Usually 4 bytes are set aside for integer variables. For positive numbers this gives 2 32 different values. With a range from 0 to 2 32 - 1 This is: 0 to 4 294 967 293 Data Representation

14 For n bits there are : 2 n different values So the RANGE is 0 to 2 n - 1 Data Representation

15 For decimals Computers use The point floats to the FRONT of the number. Take 93 000 000 This can be written.93 x 10 8 Why bother with the 10? Write it as.93 8 Why bother with the point? A computer stores it as 93 8

16 Data Representation The floating point number 93 8 Is made up of a MANTISSA: 93 And an EXPONENT: 8 Of course all this is done in binary on the computer with two’s complement for negatives.

17 With floating point storage locations have to be set aside for both the mantissa and the exponent. Decisions have to be made about how many bits for the mantissa and how many for the exponent. As you have seen this affects the range of values that can be stored. Data Representation

18 If you increase the storage for the mantissa you increase the PRECISION (accuracy) that real numbers can be stored in (more significant figures). If you increase the storage for the exponent, you increase the RANGE of numbers that can be stored. Data Representation

19 Computer pictures / images are made up of dots on paper, called pixels on a display. A typical printer will print 600 or 1200 dpi. A monitor displays 72 or 90 dpi. In black and white these pixels can be stored as a 1 or a 0. So one bit per pixel. Resolution is the number of pixels or dots used. Data Representation

20 To store colours, you need more than one bit per pixel. Colour depth is the name for how many bits are stored per pixel for colours. 1 bit gives 2 1 colours = 2 2 bits gives 2 2 colours = 4 3 bits gives 2 3 colours = 8 4 bits gives 2 4 colours = 16 8 bits gives 2 8 colours = 256 16 bits gives 2 16 colours = 65536 24 bits gives 2 24 colours = 16 777 216 (called true colour)

21 Data Representation If this was part of a screen using 4 colours 00white 01green 10red 11black Then it would be stored as shown on the left. 0100100001010101 0101011001010101 0111110010010101 0000110101100101

22 Data Representation If a computer screen has 1024 pixels along and 768 up and had 256 colours You need 8 bits per pixel: 1024 x 768 x 8 = 6291456 bits 6291456 / 8 = 786432 bytes 786432 / 1024 = 768 Kb approx.

23 Data Representation If a graphic measuring 2” by 4” is scanned at 600 dpi using true colour, what is the storage requirement for the scan? True colour needs 24 bits per pixel 2 x 4 x 600 x 600 x 24 = 69 120 000 bits 69 120 000 / 8 = 8 640 000 bytes 8 640 000 / 1024 = 8 437.5 Kb 8 437.5 / 1024 = 8.25 Mb approx.

24 Data Representation Graphics that are stored pixel by pixel are called BITMAPS. Every pixel (and its colour) is mapped to a set of bits in memory or on backing storage. There is another type of graphic storage called VECTOR GRAPHICS.

25 Data Representation Vector Graphics store graphics as individual objects. Text is an object, a square, a circle, a line etc. Each object has ATTRIBUTES. For instance in a graphics package a rectangle might be object number 3. Attributes would be things like the co-ordinates of the corners, the line colour, fill colour etc.

26 Data Representation So a rectangle might be stored as : 3, 100, 200, 400, 800, 2, 3, 5 3 means rectangle. 100, 200 is the screen co-ordinates of the bottom left corner. 400, 800 the co-ordinates of the top right corner. 2 is the colour of the line 3 the line thickness 5 the fill colour.

27 Data Representation Bitmaps use a large amount of storage You can rub out parts of a bitmap You can use paint effects in bitmap. You cannot improve the resolution of a bitmap on a better device. Vector graphics only store the objects, not the whole screen. You can edit objects in vector graphics (resize, change colour etc) You can change layers (e.g. bring to front) Resolution independent (e.g. print better quality on a better printer) Differences between bitmap and vector graphics:

28 Data Compression Because bitmaps can have such large files we need data compression for storing or transmitting them. A 5 Megapix camera using true colour needs 15 Meg for each photo. Because of this data compression is needed, for instance jpeg could reduce that 15 Meg photo to 2 Meg without any noticeable loss of quality.


Download ppt "Data Representation The storage of Text Numbers Graphics."

Similar presentations


Ads by Google