Teaching Computing to GCSE

Slides:



Advertisements
Similar presentations
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Advertisements

©Brooks/Cole, 2003 Chapter 4 Operations on Bits. ©Brooks/Cole, 2003 Apply arithmetic operations on bits when the integer is represented in two’s complement.
Assembly Language and Computer Architecture Using C++ and Java
Assembly Language and Computer Architecture Using C++ and Java
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
FIGURES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Operations on data CHAPTER 4.
© GCSE Computing Candidates should be able to:  convert positive denary whole numbers (0-255) into 8-bit binary numbers and vice versa  add two 8-bit.
Computer Systems 1 Fundamentals of Computing Negative Binary.
The Binary Number System
Data Representation Number Systems.
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
Data Representation – Binary Numbers
BINARY ARITHMETIC Binary arithmetic is essential in all digital computers and in many other types of digital systems.
Number Systems Part 2 Numerical Overflow Right and Left Shifts Storage Methods Subtraction Ranges.
Operations on Bits Arithmetic Operations Logic Operations
©Brooks/Cole, 2003 Chapter 4 Operations on Bits. ©Brooks/Cole, 2003 Apply arithmetic operations on bits when the integer is represented in two’s complement.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Candidates should be able to:
A)Convert positive denary whole numbers (0-255) into 8-bit binary numbers and vice versa b)Add two 8-bit binary integers and explain overflow errors which.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Chapter 4 Operations on Bits. Apply arithmetic operations on bits when the integer is represented in two’s complement. Apply logical operations on bits.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Representing Positive and Negative Numbers
Computer Representation of Information
CHAPTER 5: Representing Numerical Data
Lesson Objectives Aims You should know about: Binary numbers ‘n’ that.
Department of Computer Science Georgia State University
Chapter 2 Binary Number Systems.
David Kauchak CS 52 – Spring 2017
Addition and Subtraction
Digital Logic & Design Adil Waheed Lecture 02.
Negative numbers: Week 10 Lesson 1
Chapter 4 Operations on Bits.
Digital Logic & Design Dr. Waseem Ikram Lecture 02.
Boolean Algebra, Bitwise Operations
CS1001 Programming Fundamentals 3(3-0) Lecture 2
Computer Architecture & Operations I
CSE 102 Introduction to Computer Engineering
…to GCSE Level with Python Sue Sentance
Lesson objectives Understand how computers represent and manipulate numbers [unsigned integers, signed integers (sign and magnitude, Two’s complement)
CHAPTER 4: Representing Integer Data
A Level Computing Component 2
University of Gujrat Department of Computer Science
Addition and Substraction
Wakerly Section 2.4 and further
Data Structures Mohammed Thajeel To the second year students
Computer Organization and ASSEMBLY LANGUAGE
Data Representation Data Types Complements Fixed Point Representation
Digital Logic & Design Lecture 02.
Teaching Computing to GCSE
Teaching Computing to GCSE
Autumn Term Year 10 Slides
EEL 3705 / 3705L Digital Logic Design
1 The Hardware/Software Interface CSE351 Spring 2011 Module 3: Integers Monday, April 4, 2011.
C1 Number systems.
Binary “There are 10 types of people in the world: Those who understand binary, and those who don't.”
CPS120: Introduction to Computer Science
Binary to Decimal Conversion
CSC 220: Computer Organization Signed Number Representation
Data Binary Arithmetic.
GCSE COMPUTER SCIENCE Topic 3 - Data 3.2 Signed Integers.
Chapter3 Fixed Point Representation
GCSE COMPUTER SCIENCE Topic 3 - Data 3.3 Logical and Arithmetic Shifts.
Chapter 1 (Part c) Digital Systems and Binary Numbers
靜夜思 床前明月光, 疑是地上霜。 舉頭望明月, 低頭思故鄉。 ~ 李白 李商隱.
Two’s Complement & Binary Arithmetic
Presentation transcript:

Teaching Computing to GCSE Session 1 Introduction Theory: Binary Arithmetic Practical: KS3 Python Programming Recap

Course Outline Week No. Computing Theory (5:00 – 6:00) Programming in Python (6:00 – 7:30) 24th April Binary arithmetic Python programming KS3 recap 1st May Truth tables/logic diagrams For loops and while loops 8th May CPU Architecture 1-D & 2-D arrays (lists) 15th May The internet & protocols Tracing and pseudocode 22nd May Cybersecurity Functions & parameters 5th June Searching algorithms Exception handling and debugging 12th June Sorting algorithms Testing programs 19th June High level/low level languages File handling & CSV files 26th June Consolidation: Programming for GCSE with longer tasks 3rd July

Specification Content OCR How to add two 8 bit binary numbers and explain overflow errors which may occur Binary shifts AQA Be able to add together up to three binary numbers Be able to apply a binary shift to a binary number Describe situations where binary shifts can be used Edexcel Understand how computers represent and manipulate numbers (unsigned integers, signed integers (sign and magnitude, two’s complement)) Understand how to perform binary arithmetic (add, shifts (logical and arithmetic)) and understand the concept of overflow

Binary Recap Each place in a binary number has a value. These values go up in multiples of 2. We convert a binary number to decimal (aka denary) by adding the place values of the columns that contain a 1. 128 64 32 16 8 4 2 1 16 + 4 = 20

Binary Addition Recap For the AQA specification you need to be able to add together up to three binary numbers. 1 Rules: 0+1 = 1 1+1 = 10 (write down 0, carry 1) 1+1+1 = 11 (write down 1, carry 1) 1+1+1+1 = 100 (write down 0, carry 0, carry 1) 94 86 36 216

Negative Numbers Sign and Magnitude Two’s Complement There are two different methods of representing negative numbers in binary: In both systems the most significant bit is known as the ‘sign bit’. Sign and Magnitude Two’s Complement

Sign and Magnitude 0 = plus (+) 1 = minus (-) = -20 Sign and magnitude is the simplest way of representing negative numbers in binary. In sign and magnitude the sign bit doesn’t have a value, it simply tells us whether the number is positive or negative. 0 = plus (+) 1 = minus (-) Sign 64 32 16 8 4 2 1 = -20

Activity 1a Convert the following binary numbers that use sign and magnitude representation to decimal. Sign 64 32 16 8 4 2 1 Decimal

Activity 1b Convert the following decimal numbers to binary numbers that use sign and magnitude representation to decimal. Use paper for working out. Decimal Sign 64 32 16 8 4 2 1 -73 -91 46 102

The Problem with Sign and Magnitude Sign and magnitude might be simple, however it causes problems when performing binary addition. Two’s complement is an alternative method of representing negative binary numbers that works with binary addition.

Two’s Complement -128 + 64 + 32 + 8 + 4 = -20 In two’s complement the sign bit is a negative number. Just like a normal binary number, we convert it to decimal by adding the place values together. -128 64 32 16 8 4 2 1 -128 + 64 + 32 + 8 + 4 = -20

Flipping the Bits We can easily work out the positive equivalent of a negative two’s complement number using the ‘flipping the bits’ method. Finally we add a minus sign, as the original number is negative. 128 64 32 16 8 4 2 1 Original Number Flip the bits Add 1 = 20 = -20

Activity 2a Convert the following binary numbers that use two’s complement representation to decimal. Sign 64 32 16 8 4 2 1 Decimal

Activity 2b Convert the following decimal numbers to binary numbers that use two’s complement representation to decimal. Use paper for working out. Decimal Sign 64 32 16 8 4 2 1 -73 -91 46 102

Logical Shift Logical shift can be used to easily multiply and divide number by powers of 2. A logical left shift of 1 multiplies the number by 2. A logical right shift of 1 divides the number by 2. We pad out any empty places with 0s. 128 64 32 16 8 4 2 1 1 1 1 1

Activity 3 a) Perform a logical left shift of 1 on this number. a) Perform a logical left shift of 2 on this number. 128 64 32 16 8 4 2 1 Decimal Original Shifted 128 64 32 16 8 4 2 1 Decimal Original Shifted

Activity 4 a) Perform a logical right shift of 1 on this number. a) Perform a logical right shift of 2 on this number. 128 64 32 16 8 4 2 1 Decimal Original Shifted 128 64 32 16 8 4 2 1 Decimal Original Shifted

Shifting Signed Integers Logical shift won’t work with negative numbers represented in two’s complement binary. When we shift the number to the right we loose the sign bit, giving us the wrong result. -128 64 32 16 8 4 2 1 1 = -112 1 = 72

Arithmetic Shift Arithmetic shift solves the problem of shifting a negative two’s complement to the right. With arithmetic shift, when shifting a number to the right we pad out the empty spaces with a copy of the sign bit. When shifting to the left we still fill the empty places with 0s. -128 64 32 16 8 4 2 1 1 = -112 1 1 = -56

Activity 5 a) Perform an right arithmetic shift of 1 on this two’s complement number. a) Perform a right arithmetic shift of 2 on this two’s complement number. -128 64 32 16 8 4 2 1 Decimal Original Shifted -128 64 32 16 8 4 2 1 Decimal Original Shifted

Activity 6 a) Perform an left arithmetic shift of 1 on this two’s complement number. a) Perform a left arithmetic shift of 2 on this two’s complement number. -128 64 32 16 8 4 2 1 Decimal Original Shifted -128 64 32 16 8 4 2 1 Decimal Original Shifted

Break After the break we will recap Python Programming for KS3