Shawlands Academy Higher Computing Data Representation
1 Data Representation 1.2 Numbers Numbers are converted to binary – number base 2 Example of 154 represented as a binary number =154
1 Data Representation 1.2 Numbers R1 217R0 28R1 24R R1 How to convert decimal to binary e.g. 69 Giving Keep dividing by 2 Note the remainders Read the remainders from the bottom up
Range of Numbers Using 1 byte for storage gives 256 (2 8 ) possible numbers in the range bytes gives 65536(2 16 ), Increasing the size of the storage for numeric data increases the range of numbers which can be stored.
Data Representation 1.3 Integers Positive numbers Converted directly to binary 2 bytes = 16 bits gives 0 to or 0 to 65535
Negative Numbers - more difficult One of the 16 bits available has to be used to store the sign (- or +) – this reduces the range of numbers to –32768 to This is called Signed Bit representation
Problems with Signed Bit Representation Does not always work because: Addition does not work properly ( gives 15) Two values for 0 ( and )
To overcome problems Twos Complement –Addition works and there is only one zero –All 0’s are converted to 1’s and 1’s to 0’s then 1 is added. –To convert 5 to – OR 5 OR -5
Data Representation 1.4 Real Numbers Real numbers are stored as floating point. E.g is *10 5 In binary is *2 100 (the 4is 100 in binary) The mantissa is and the exponent is 100 Usually 4 bytes used for mantissa and 2 for exponent Increasing the size of the mantissa increases accuracy Increasing the size of the exponent increases the range of numbers which can be stored
1 Data Representation 1.1 Text Each character is stored as an 8 bit binary code This is called the ASCII system. E.g. A is stored as 65 ( in Binary). 1 byte can store 256 (2 8) different characters – enough for all the keys on the keyboard and several foreign symbols (for currency etc )
Data Representation 1.5 Bit-mapped Graphics For a graphic drawn in a painting package the computer stores the data as a 2 dimensional array of pixels. Each pixel in a black and white image is 1 bit in memory. 2 bits can store 4 colours or shades of grey.(2 2 ) 8 bits can store 256 colours.(2 8) 2 bytes can store 65,536 colours.(2 16 ) Bit mapped images are often generated from scanned pictures and can create huge files. Editing can be performed at pixel level. When images are enlarged they can become “lumpy” and lose definition.
Data Representation 1.6 Vector Graphics Sometimes called object-orientated graphics. Used in CAD, drawing and publishing packages. Describes an object by its attributes (start & end positions, thickness & colour of lines etc.) Editing at pixel level not possible. Can be resized without losing original sharpness. Can be placed over another graphic without rubbing it out as happens with bit-mapped.