Survey

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Survey

Document related concepts

Transcript

Higher Grade Computing Studies 1. Data Representation Data Representation – Why do we use binary? • simplicity, in only having to generate and detect two voltage levels. • good tolerance, because a degraded 1 is still recognisable as a 1. • calculations are kept simple. 1 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Numbers • Converting binary to decimal Here is an example of how to convert the binary number 10011010 to a decimal: 128 1 64 0 32 0 16 1 8 1 4 0 2 1 = 128 + 16 + 8 + 2 = 154. 2 Higher Computing Computer Systems S. McCrossan 1 0 Higher Grade Computing Studies 1. Data Representation Data Representation - Numbers • Converting decimal to binary Here is an example of how to convert the decimal number 69 to a binary: 3 2 2 2 2 2 2 2 2 69 34 17 8 4 2 1 0 R1 R0 R1 R0 R0 R0 R1 giving 1000101 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Numbers • Positive and Negative Integers • Twos complement representation is used to store both positive and negative numbers. • The leftmost bit is used to store whether a number is positive or negative. 4 Binary Integer 11111101 -3 11111110 -2 11111111 -1 00000000 0 00000001 1 00000010 2 00000011 3 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Numbers • Positive and Negative Integers To convert 5 to –5 you change all 0s to 1s and vice versa and then add 1. So 0 0 0 0 0 1 0 1 becomes 1 1 1 1 1 0 1 0 +1 1 1 1 1 1 0 1 1 5 or 5 or -5 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Numbers • Positive and Negative Integers The number of integers which could be stored in one byte ( 8 bits ) is 28 = 256 The range of integers which could be stored in one byte ( 8 bits ) is -128 to +127 6 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Numbers • Real Numbers • A real number is a number like 134.78954673. Real numbers are stored in a computer as floating point numbers. • In decimal base 10, 34006.8 becomes 3.40068 * 104 • The ‘4’ is because the point has moved 4 places to the left. • The ‘3.40068’ is called the mantissa. • The ‘4’ is called the exponent. 7 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Numbers • Real Numbers • The binary real number 1101.0011011101 would be written as .11010011011101 * 24 where the 2 is because we are working in binary and the 4 is the number of places that the point has moved. • The full answer is .11010011011101 *2100 because the 4 is converted into binary as well. • The computer would store the mantissa 11010011011101 and exponent 100. Higher Computing 8 Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Numbers • Storage of Numbers • Increasing the size of the storage for numeric data increases the range of numbers that can be stored. • Increasing the size of the mantissa increases the accuracy with which the real number can be stored. • Increasing the size of the exponent increases the range of numbers that can be stored. 9 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Text • Each character is stored in the computer as a unique binary code. • The list of characters that a computer can handle is called the character set. • ASCII character set was introduced so that all computers would use the same codes to represent the same characters • Control characters are included in the character set that tell the computer to do things, for instance, take a new page or take a newline. 10 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Text • ASCII can only represent, at most, 256 characters. However, other alphabets need many more characters, e.g. Japanese and Arabic. • The solution was Unicode which uses 16 bits to represent each character. This means it can store 65,536 characters. 11 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Graphics Bit mapped Graphics • For a graphic drawn in a painting package, the computer stores it as a two-dimensional array of pixels • The number of pixels that makes up an image is called the resolution. 12 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Graphics Bit mapped Graphics • In a black and white display, each white pixel is represented by a 0. • In a black and white display, each black pixel is represented by a 1. • Only two values, 1 and 0, need to be stored as there are only two colours to be used. 13 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Graphics Bit mapped Graphics • However, when more than two colours are used we need more memory to store the colour value for each pixel. • In an 8 colour display, each white pixel is represented by a 000. • In an 8 colour display, each black pixel is represented by a 001. • In an 8 colour display, each yellow pixel is represented by a 011. 14 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Graphics Bit mapped Graphics • The number of bits used to represent the colour of the pixels is called the bit depth. 15 Bit depth 1 2 3 Colours 2 4 8 8 256 16 65536 24 16777216 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Graphics Bit mapped Storage Requirements An image, 5in by 7in is stored at 600 dpi in 65536 colours. How much memory would be required to store this image? Pixels used to store image = 5 x 7 x 600 x 600 = 12600000 65536 colours = 16 bits = 2 bytes Amount of memory 16 = 12600000 x 2 bytes = 25200000 bytes = 24Mb Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Graphics Bit mapped Graphics • The advantage of using bit mapped graphics is that you have more control over the graphic as you are able to go into detail and edit the graphic pixel by pixel. • The disadvantage of using bit mapped graphics is that each picture or graphic takes up a lot of memory as the colour of each pixel has to be stored. • Another disadvantage of using bit mapped graphics is that if you enlarge a bitmap image it becomes ‘blocky’. 17 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Graphics Vector Graphics • In a CAD or drawing package, the computer stores information about an object by its attributes i.e. a description of how it is to be drawn. • For a rectangle it might be: • start x and y position • length, breadth and angle of rotation • thickness and colour of the lines • colour fill etc. 18 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 1. Data Representation Data Representation - Graphics Vector Graphics • The advantage of using vector graphics is that you edit shapes. This allows you to scale the graphic easily. It also means that vector graphics don’t take up a lot of memory. • The disadvantage of using vector graphics is that you are limited to using only the shapes that the package offers. This can mean that only simple graphics can be created. 19 Higher Computing Computer Systems S. McCrossan