Presentation is loading. Please wait.

Presentation is loading. Please wait.

OCR Computing OGAT 1.4.1 Data Types. What OCR need you to know… 1.4.1 Data Types a) Primitive data types, integer, real/floating point, character,

Similar presentations


Presentation on theme: "OCR Computing OGAT 1.4.1 Data Types. What OCR need you to know… 1.4.1 Data Types a) Primitive data types, integer, real/floating point, character,"— Presentation transcript:

1 OCR Computing AS @ OGAT 1.4.1 Data Types

2 What OCR need you to know… 1.4.1 Data Types a) Primitive data types, integer, real/floating point, character, string and Boolean. b) Representing positive integers in binary c) Use of sign and magnitude and two’s complement to represent negative numbers in binary. d) Addition and subtraction of binary integers e) Represent positive integers in hexadecimal f) Convert positive integers between binary, hexadecimal and denary. g) Positive and negative real numbers using normalised floating point representation. h) How character sets (ASCII and UNICODE) are used to represent text.

3 Tasks 1.When declaring a variable, what two pieces of information did you need to provide? 2.For each of the following data types, describe and give an example of the data that they can store. (Use a table like shown above) A)Character B) String C) Boolean D) Integer E) Real/Floating Point 3. What data type is used to store a date? How can a date be calculated from this? Data Types Data TypeDescriptionExample Character String Boolean Integer Real/Floating Poi nt

4 Tasks 1.How is text represented by a computer? 2.What is a character set? 3.What does ASCII stand for? How many characters can it represent? Why? 4.What is the ASCII extended character set? How many characters can this represent? Why? 5.What is the main issue with the ASCII character set? Why? 6.What is UNICODE? How is this different to ASCII? Why is this preferable to ASCII? 7.How many characters can 16 bit UNICODE represent? Representing Text

5 Tasks 1.How are bitmap and vector images constructed by a computer? 2.If a pixel in a bitmap image uses the following the following number of bits to store a colour, how many colours can it store? How is this calculated? a) 1 bit b) 2 bits c) 4 bits d) 8 bits e) 16 bits 3. What is metadata? What does it contain? Why is it needed for constructing images? 4. Explain how the increase in colour depth and/or resolution affects the file size of a bitmap image. 5. Why does the file size of a vector file not increase when you increase the size of the image? Representing Images

6 Tasks 1.For a computer to represent a sound (analogue), what must it do? 2.What is sampling? 3.What is sample rate? How does it affect the quality of the sound? 4.What is the bit rate? How does it affect the quality of the sound? 5.If you increase the bit rate and sample rate, what happens to the file size? Why? Representing Sound

7 Tasks 1.What is the opcode/operator? 2.What is the operand? 3.How does the computer distinguish between data and instructions? Representing Instructions In a simple 8-bit instruction, 1001 represents the instruction to add the value fou nd in a memory location to the accumulator. If the following instruction is fetched : 10011101 11011001 Opcode/operator Add to the accumulator Operand The value found in memory location 1101

8 Tasks 1.Create a worked example of converting the number 10110111 to denary. 2.Complete the questions on the worksheet (Task 1 – Representing Positive Integers) Binary to Denary Denary is our number system and is kno wn as base-10, as it can be represented usi ng 10 numbers (0-9). The column value s are powers of 10 Binary is known as base-2, as it can be represented using 2 numbers (0 or 1 ). The column values are powers of 2.

9 Tasks 1.Create a worked example of converting the number 194 den to binary 2.Complete the questions on the worksheet (Task 1 – Representing Positive Integers) Denary to Binary To convert denary to binary, you should find the highest number that goes i nto the number you have been given. E.g If you have the number 157 and want to convert to binary. 1286432168421 10011101 128 goes into 157, therefore has a 1. Then subtract that number from 157 (157-128) = 29 Neither 64 or 32 go into 29, therefore they have a 0. 16 goes into 29, therefore has a 1. The n subtract that number from 29 (29-16) = 13. 8 goes into 13, therefore it has a 1, which then l eaves 5 (13-8). 4 goes into 5, therefore it has a 1, which then leaves 1 (5-4). 2 doesn’t go into 1, therefore ha s a 0. 1 goes into 1 and therefore has a 1.

10 Tasks 1.Define the term most significant bit (MSB) 2.Using the helpsheet create a worked example for representing the number -72 den in binary using sign and magnitude 3.Using the helpsheet create a worked example for representing the number -72 den in binary using two’s complement 4.What are the largest and smallest values that can be stored in eight bits using sign and magnitude? 5.What are the largest and smallest values that can be stored in eight bits using two’s complement? 6.Complete the questions on the worksheet (Task 2 – Representing Negative Integers) Representing Negative Numbers Using an 8-bit binary code you can represent positive values 0 to 255, how ever you cannot represent negative numbers. There are two ways in which you can do this: Sign and magnitude Two’s complement Column Value-1286432168421 Column Value+/-6432168421 Two’s Complement Sign and Magnitude

11 Tasks 1.What are the five rules when adding in binary? 2.Using the helpsheet create a worked example for adding the number 11001011 + 00011111 3.What issue occurs when you add two binary numbers that equal over 255? What happens to the completed calculation? 4.What issue can occur when adding two 2s Complement numbers? 5.Complete the questions on the worksheet (Task 3 – Adding & Subtracting Binary Integers) Adding in Binary The process of adding together two numbers in binary is s imilar to the process we use for denary, for example if we add 64 and 19 the steps are: Add 4 and 9, this is 13, so we write down 2 and carry t he 1 to the next column. Add 6, 1 and the carried 1 to get 8, we write down 8 64 19 83 1 In binary, you do the same except, w hen you reach 2 instead of 10, you c arry the 1 00001011 10011011 10100110 1 1 1 1

12 Tasks 1.Using the helpsheet provided, show worked examples for subtracting the following: a)10110111 – 00011111 (both numbers are 2s Complement) b)11110000 – 01101010 (unsigned, using method 1) c)10110011 – 00101101 (unsigned, using method 2) 2.What are the five rules to follow if using method 2 to subtract two unsigned binary integers. 3.Complete the questions on the worksheet (Task 3 – Adding & Subtracting Binary Integers) Subtracting in Binary To subtract in binary there are different methods you can use. If you are using signed binary numbe rs you will use a different method to if you are not. The different methods you can use are: Signed - To subtract 2s Complement numbers you add. Unsigned - Using one’s complement with unsigned binary integers Unsigned - Borrowing from the next column like in denary For the two unsigned methods, you need to try both and decide which one you are more comfortable with and stick with that.

13 Tasks 1.Explain why hexadecimal is used if computers cannot understand it. 2.Complete the questions on the worksheet, converting denary → binary → hexadecimal (Task 4 – Hexadecimal Conversions) Hexadecimal Computers do not work in hexadecimal but it is often used to represent numbers stored in a co mputer. Hexadecimal is known as base-16 as the column values are powers of 16. DenaryBinaryHexadecimal 000000 100011 200102 300113 401004 501015 601106 701117 DenaryBinaryHexadecimal 810008 910019 101010A 111011B 121100C 131101D 141110E 151111F Column Value 4096 = 16 3 256 = 16 2 16 = 16 1 1 = 16 0

14 Tasks 1.Complete the following standard form questions, show your working: a)0.123 x 10 6 b) 3.27 x 10 3 c) 8.1256 x 10 3 d) 0.098 x 10 7 e) 5.45967 x 10 5 f)5720 g) 7.4 h) 473000 i) 0.09 j) 0.000621 Real Numbers in Binary To understand how to represent real numbers in binary, you must first of all understand standar d form in the denary number system. In standard form a number is always written A x 10 n. A is a number between 1 and 10 and n tells us how many places to move the decimal point. Example – write 15000000 in standard form 15000000 = 1.5 x 10000000 This can be written as 1.5 x 10 x 10 x 10 x 10 x 10 x 10 x 10 = 1.5 x 10 7 Example – write 3.15 x 10 4 in denary 3.15 x 10 4 = 3.15 x 10000 = 31500 This is because 10 4 = 10 x 10 x 10 x10 = 10000

15 Tasks 1.Explain what the mantissa is. 2.Explain what the exponent is. 3.Using the helpsheet create a worked example for converting the 2s complement floating point binary number 0101001001 001000 to denary with a 10-bit mantissa and 6-bit exponent. 4.Using the helpsheet create a worked example for converting the denary number 14.875 to a 2s complement floating point binary number with a 10-bit mantissa and 6-bit exponent. 5.Complete the questions on the worksheet (Task 5 – Floating Point Numbers Task A & B) Real Numbers in Binary Now you understand how standard form works, representing real numbers in binary works in exactly the same way, however instead of powers of 10 it uses powers of 2. Instead of being called standard form it is called floating point (because the decimal point moves!) A binary code is broken up into two parts, the mantissa and the exponent, like in denary we use the notation A x 2 n. A is the mantissa and n the exponent. A is a number either 0 or 1 with n telling us how many places to move the decimal point. **************** Column Value-32168421 10-bit mantissa in two’s complement6-bit exponent in two’s complement

16 Tasks 1.How is the accuracy of a floating point number affected if the size of the mantissa is increased/reduced? 2.How is the accuracy of a floating point number affected if the size of the exponent is increased/reduced? 3.What value 0 or 1 is the MSB in a positive floating point number? 4.To normalise a positive floating point number what must you ensure? 5.What value 0 or 1 is the MSB in a negative floating point number? 6.To normalise a negative floating point number what must you ensure? 7.How can you tell if a binary number has already been normalised? 8.Using the helpsheet create a worked example for normalising the positive binary number (10-bit mantissa, 6-bit exponent) 0000110111000110 9.Using the helpsheet create a worked example for normalising the negative binary number (10-bit mantissa, 6-bit exponent) 1101100000 111101 10.Complete the questions on the worksheet (Task 5 – Floating Point Numbers Task C) Normalisation of Floating Point Numbers When using floating point numbers, there is a balance between the range and precision depending on the choi ce of numbers of bits for the mantissa and exponent. Floating point numbers need to be normalised to maximise the accuracy of the number.


Download ppt "OCR Computing OGAT 1.4.1 Data Types. What OCR need you to know… 1.4.1 Data Types a) Primitive data types, integer, real/floating point, character,"

Similar presentations


Ads by Google