PYTHON PROGRAMING Week 15 – Tuesday.

Slides:



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

DATA REPRESENTATION Y. Colette Lemard February
Number Systems Discussion D4.1 Appendix C. Number Systems Counting in Binary Positional Notation Hexadecimal Numbers Negative Numbers.
J. Michael Moore Computer Organization CSCE 110. J. Michael Moore High Level View Of A Computer ProcessorInputOutput Memory Storage.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Review Two’s complement
Agenda Shortcuts converting among numbering systems –Binary to Hex / Hex to Binary –Binary to Octal / Octal to Binary Signed and unsigned binary numbers.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Negative Numbers Module M3.3 Section 2.4. Negative Numbers Subtract by adding ’s complement Ignore carry.
Mathematics with Binary. Question  Below is a binary string  Which is the least significant bit (LSB)?  Which is the most significant bit (MSB)? 0.
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Number Systems and Codes Discussion D4.1. Number Systems Counting in Binary Positional Notation Hexadecimal Numbers Negative Numbers.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Introduction to Number Systems
© 2010 Kettering University, All rights reserved..
Binary Representation - Shortcuts n Negation x + x = 1111…1111 two = -1 (in 2’s complement) Therefore, -x = x + 1 n Sign Extension o Positive numbers :
1 Week 3: Data Representation: Negative Numbers READING: Chapter 3.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Integer Data representation Addition and Multiplication.
Numbering systems.
Data Representation – Binary Numbers
A-Level Computing Data representation. Objectives Know how data can be represented in a computer system Understand the need for various forms of representation.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
PYTHON PROGRAMMING Week 14 – Tuesday. STARTER You need to find out the average of a set of exam marks for a class. You don’t know how many marks there.
Data Representation - Part I. Representing Numbers Choosing an appropriate representation is a critical decision a computer designer has to make The chosen.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Binary Arithmetic In today’s lesson we will look at: a reminder of how binary works adding binary numbers overflow complements negative numbers and subtraction.
Calculating Two’s Complement. The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of.
Number Systems. Today Decimal Hexadecimal Binary –Unsigned Binary –1’s Complement Binary –2’s Complement Binary.
Representation of Data Ma King Man. Reference Text Book: Volume 2 Notes: Chapter 19.
The Teacher CP4 Binary and all that… CP4 Revision.
Positional Number Systems
ECE2030 Introduction to Computer Engineering Lecture 2: Number System Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Tech.
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
The Teacher CP4 Binary and all that… CP4 Revision.
CS41B MACHINE David Kauchak CS 52 – Fall Admin  Assignment 3  due Monday at 11:59pm  one small error in 5b (fast division) that’s been fixed.
Number Systems and Logic Prepared by Dr P Marais (Modified by D Burford)
By Jariya Phongsai A two's-complement system is a system in which negative numbers are represented by the two's complement of the absolute value; this.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Two’s Complement. A system used to represent a negative number in binary A system used to represent a negative number in binary Positive numbers start.
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
Addition and Substraction
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.6 Instructor: Lin Chen Sept 2013.
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
IT1004: Data Representation and Organization Negative number representation.
Lec 11Systems Architecture1 Systems Architecture Lecture 11: Arithmetic for Computers Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some or all.
In decimal we are quite familiar with placing a “-” sign in front of a number to denote that it is negative The same is true for binary numbers a computer.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
May 2, 2001System Architecture I1 Systems Architecture I (CS ) Lecture 11: Arithmetic for Computers * Jeremy R. Johnson May 2, 2001 *This lecture.
Lecture 2: 8/29/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
Two’s Complement The language of machines, part II.
Starter Using the mini whiteboards record your answers: 1) Name 2 different Character Sets 2) Convert the Hex number 9E into denary 3) Convert the binary.
Starter Using two’s Complement form convert the following from Denary to Binary using 8 bits. Answer on mini whiteboard Using two’s.
Binary Arithmetic James A. Rome Tennessee Governor's Academy August 2010.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Binary numbers: Week 7 Lesson 1
Binary Addition (1 of 2) Two 1-bit values A B A + B 1
Presentation transcript:

PYTHON PROGRAMING Week 15 – Tuesday

have a go Convert these denary numbers to binary: 23, 45, 62, 8, 14 Now convert them to hexadecimal Convert these hexadecimal numbers to binary: 3D, 1A, FF, 0F, 56 Now convert them to denary Work out these in binary: 23 + 45 62 + 8 8 * 14 14 * 62

last week Bitwise operators Binary addition Binary multiplication Hexadecimal (base 16) Denary to hex Hex to denary

today Targets!! Representing negative numbers in binary (Two’s complement) Binary subtraction Representing fixed point fractional numbers in binary File handling in Python

setting targets – comp1 & comp2 academic? maths? english?

twos complement Have you watched the videos? Representation of negative numbers Most significant bit holds sign 0 – positive 1 - negative Flip the bits Add 1 Negative 1 will always be all 1s in twos complement Smallest negative number will always be a leading 1 followed by zeroes Largest positive number will always be a leading zero followed by ones

binary addition– twos complement How do you think we do this?

binary subtraction – twos complement How do you think we do this? What is the advantage of this when it comes to designing computer architecture? NB Overflow adding two positives giving a negative number (eg 3 bit system 3 + 2) adding two negatives giving a positive number (eg 3 bit system -4 -7)

fixed point fractions in binary What is fixed point How do we represent the fractional part? .5 .1 .25 .01 .125 .001 .0625 .0001 …. How can we represent other fractions eg .75, .375 …

exercises Text book page 107 Questions 6-9 page 108 Questions 10-11 plus any of the activites

Python - file handling Codecademy Where are you? What is your target for this week? Try the file handling exercises on the web site Do I need to go through file handling programs? Smaller group? NB example programs and notes are also on the site

PLENARY How do we represent a negative number in binary? How many values can we represent in 4 bits? How many values can we represent in 8 bits? What is the largest positive number we can hold in a four bit signed system? What is the smallest negative number in a four bit signed system? What is the process for twos complement? How do we do binary subtraction? What is a fixed point number? How do we represent a fixed point number in binary? How did we get on with file handling?

tomorrow Revision for mock exam Exam questions Binary, hex, twos complement … Algorithm design tools Creating programs from designs

homework Have a look at revision topics and bring any questions tomorrow