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,

Slides:



Advertisements
Similar presentations
The Binary Numbering Systems
Advertisements

Boolean Algebra. Starter Task State 5 basic data types together with one operation that can be performed on each. We have looked at 4 in the past few.
Binary Representation Introduction to Computer Science and Programming I Chris Schmidt.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, Java Version, Third Edition.
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
Data Representation Computer Organization &
Lecture 3 Number Representation 2 This week – Recap Addition – Addition circuitry – Subtraction of integers in binary – Representing numbers with fractional.
Data Representation COE 205
Assembly Language for Intel-Based Computers, 4th Edition
2-1 Computer Organization Part Fixed Point Numbers Using only two digits of precision for signed base 10 numbers, the range (interval between lowest.
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
Binary Number Systems.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Binary Representation and Computer Arithmetic
Chapter 5 Data representation.
The Binary Number System
Simple Data Type Representation and conversion of numbers
Higher Computing Data Representation.
Lecture 5.
Binary Representation. Binary Representation for Numbers Assume 4-bit numbers 5 as an integer  as an integer  How? 5.0 as a real number  How?
Computing Higher - Unit 1… Computer Systems 1 Higher Computing Unit 1 – Topic 1 Data Representation.
Computers Organization & Assembly Language
IT253: Computer Organization
Higher Computing Computer Systems S. McCrossan 1 Higher Grade Computing Studies 1. Data Representation Data Representation – Why do we use binary? simplicity,
Shawlands Academy Higher Computing Data Representation.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Why does it matter how data is stored on a computer? Example: Perform each of the following calculations in your head. a = 4/3 b = a – 1 c = 3*b e = 1.
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
The Teacher CP4 Binary and all that… CP4 Revision.
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
CSC 221 Computer Organization and Assembly Language
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
The Teacher CP4 Binary and all that… CP4 Revision.
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
Data Representation The storage of Text Numbers Graphics.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
Number Systems Denary Base 10 Binary Base 2 Hexadecimal Base 16
1 Information Representation in Computer Lecture Nine.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Floating Point Binary A2 Computing OCR Module 2509.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
 Computers are 2-state devices › Pulse – No pulse › On – Off  Represented by › 1 – 0  BINARY.
Software Design and Development Storing Data Computing Science.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Advanced Binary b. describe and use two’s complement and sign and magnitude to represent negative integers; c. perform integer binary arithmetic, that.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Floating Point Numbers
Objectives Today: P4 Data Types – Floating Points P4 Variable Quiz P3 Iteration and Selection Practical Are you logged on? Then come around the table Unit.
Data Representation COE 308 Computer Architecture
Data Representation ICS 233
Lec 3: Data Representation
Data Representation.
Data Representation Binary Numbers Binary Addition
CS1010 Programming Methodology
Folders out, planners out…
Chapter 2 Bits, Data Types & Operations Integer Representation
1. Explain how ASCII is used to represent text in a computer system
How are negative and rational numbers represented on the computer?
A-level Computer Science
23/04/2019 Data Representation Conversion.
Data Representation COE 308 Computer Architecture
Section 6 Primitive Data Types
Presentation transcript:

OCR Computing OGAT Data Types

What OCR need you to know… 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.

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

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

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

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

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 : Opcode/operator Add to the accumulator Operand The value found in memory location 1101

Tasks 1.Create a worked example of converting the number 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.

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 goes into 157, therefore has a 1. Then subtract that number from 157 ( ) = 29 Neither 64 or 32 go into 29, therefore they have a goes into 29, therefore has a 1. The n subtract that number from 29 (29-16) = 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.

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 Column Value+/ Two’s Complement Sign and Magnitude

Tasks 1.What are the five rules when adding in binary? 2.Using the helpsheet create a worked example for adding the number 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 In binary, you do the same except, w hen you reach 2 instead of 10, you c arry the

Tasks 1.Using the helpsheet provided, show worked examples for subtracting the following: a) – (both numbers are 2s Complement) b) – (unsigned, using method 1) c) – (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.

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 DenaryBinaryHexadecimal A B C D E F Column Value 4096 = = = = 16 0

Tasks 1.Complete the following standard form questions, show your working: a)0.123 x 10 6 b) 3.27 x 10 3 c) x 10 3 d) x 10 7 e) x 10 5 f)5720 g) 7.4 h) i) 0.09 j) 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 in standard form = 1.5 x 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 = This is because 10 4 = 10 x 10 x 10 x10 = 10000

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 to denary with a 10-bit mantissa and 6-bit exponent. 4.Using the helpsheet create a worked example for converting the denary number 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 bit mantissa in two’s complement6-bit exponent in two’s complement

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) Using the helpsheet create a worked example for normalising the negative binary number (10-bit mantissa, 6-bit exponent) 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.