Introduction to Programming Part 3

Slides:



Advertisements
Similar presentations
Binary Numbers.
Advertisements

Intro CS, Computers, Programming Introduction to Computer Science, Computers, and Programming Barbara Ericson Georgia Tech Aug 2009.
01- Intro-Java-part1 1 Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology June 2008.
Abstraction – Number Systems and Data Representation.
Georgia Institute of Technology Introduction to Programming Part 2 Barb Ericson Georgia Institute of Technology May 2006.
Georgia Institute of Technology Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology Aug 2005.
Algebra 8.4 Scientific Notation.
Addition and Substraction
Binary01.ppt Decimal Decimal: Base 10 means 10 Unique numerical digits ,00010,000 Weight Positions 3,
Aim: How to write in Scientific Notation DO NOW: 1. WHAT DOES 10 5 MEAN? 2. WHAT IS THE VALUE OF USING YOUR CALCULATOR, CALCULATE 4.5 X 10 6.
1 4. Computer Maths and Logic 4.1 Number Systems.
Georgia Institute of Technology Introduction to Programming Part 3 Barb Ericson Georgia Institute of Technology May 2006.
Scientific Notation SWBAT write the scientific notation for numbers given in standard form; write the standard form for numbers given in scientific notation;
Scientific Notation. Can be also called standard form or exponential notation Can be also called standard form or exponential notation Used to write numbers.
Significant Figures Box and Dot Method. Step 1  Draw a box around all nonzero digits, beginning with the leftmost nonzero digit and ending with the rightmost.
Mental Arithmetic Strategies Scotts Primary School. Mental Arithmetic Scheme.
Department of Computer Science Georgia State University
Draw two number lines from 0 – 5.
David Kauchak CS 52 – Spring 2017
Introduction to Programming Part 1
Binary, Denary, Hexadecimal Conversion Binary Addition
Scientific Notation Objective: Students will be able to convert between scientific notation and regular notation and solve problems involving scientific.
Scientific Notation Exponent Unit.
Adding, Subtracting, Multiplying, and Dividing Integers
Integers’ Representation. Binary Addition. Two's Complement.
Introduction to Programming Part 2
Exploring Computer Science – Lesson 2-5
Scientific Notation.
7-4 Scientific Notation Goals:
SCIENTIFIC NOTATION Lesson 8-2
Integer Real Numbers Character Boolean Memory Address CPU Data Types
Significant Figures.
Boolean Algebra, Bitwise Operations
Data Representation Integers
Scientific Notation.
Unit 1 Rational Numbers Integers.
A Level Computing Component 2
Multiply Decimals L-2 6.NS.3.
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Addition and Substraction
Binary Arithmetic.
SCIENTIFIC NOTATION.
Scientific Notation.
Introduction to Java, and DrJava part 1
Fundamentals of Data Representation
Binary / Hex Binary and Hex The number systems of Computer Science.
Introduction to Binary
Unit 18: Computational Thinking
Introduction to Programming Part 2
Plan Attendance Files Posted on Campus Cruiser Homework Reminder
Storing Negative Integers
Binary “There are 10 types of people in the world: Those who understand binary, and those who don't.”
How Computers Store Data
Computer Organization
CPS120: Introduction to Computer Science
Introduction to Java, and DrJava
Scientific Notation.
7-4 Scientific Notation Goals:
Scientific Notation & Significant Figures
Multiplying and Dividing in Scientific Notation
Introduction to Programming Part 3
Percents and Decimals Objective:
Abstraction – Number Systems and Data Representation
Introduction to Java, and DrJava
Introduction to Java, and DrJava part 1
SCIENTIFIC NOTATION ... a way to express very small or very large numbers that is often used in "scientific" calculations where the analysis must be very.
SCIENTIFIC NOTATION 5.67 x 105 Coefficient Base Exponent
靜夜思 床前明月光, 疑是地上霜。 舉頭望明月, 低頭思故鄉。 ~ 李白 李商隱.
Two’s Complement & Binary Arithmetic
Presentation transcript:

Introduction to Programming Part 3 Barb Ericson Georgia Institute of Technology Aug 2005 Georgia Institute of Technology

Georgia Institute of Technology Learning Goals Understand at a conceptual level Binary Numbers How to add binary numbers 2’s compliment notation How to subtract a number from another How many patterns do you have with n number of bits? Why does it matter? Georgia Institute of Technology

Georgia Institute of Technology Binary Numbers We usually work with decimal numbers with digits from 0 to 9 and powers of 10 7313 = (7 * 1000 + 3 * 100 + 1 * 10 + 3 * 1) Or (7 * 103 + 3 * 102 + 1 * 101 + 3 * 100) The binary number system uses digits 0 and 1 and powers of 2 0101 = (0 * 8 + 1 * 4 + 0 * 2 + 1 * 1) Or (0 * 23 + 1 * 22 + 0 * 21 + 1 *20) = 5 See http://computer.howstuffworks.com/bytes1.htm for more information on number systems and binary numbers. Georgia Institute of Technology

Georgia Institute of Technology Binary Addition To add two decimal numbers you add the digits and if the total is greater than ten you carry the one into the next column To add two binary numbers 0 + 0 = 0 0 + 1 and 1 + 0 = 1 1 + 1 = 0 with a carry of 1 into the next column to the left 00 10 111 01 01 001 ---- --- ------ 01 11 1000 00111001010 01010101101 ------------------- 10001110111 Georgia Institute of Technology

2’s Compliment Notation Computers actually only know how to add So, how do they handle subtraction? Computers subtract by adding a negative number How do you represent a negative number in memory? Positive numbers in 2’s compliment are just the same as a binary number For negative numbers reverse 0s and 1s and then add 1 All negative numbers have a one for the leftmost bit See http://gs.fanshawec.ca/tlc/math270/1_7_Two's_Comp_Arith.htm and http://courses.cs.vt.edu/~csonline/NumberSystems/Lessons/SubtractionWithTwosComplement/Lesson.html for information on 2’s compliment Georgia Institute of Technology

Georgia Institute of Technology 2’s Compliment Example To subtract 3 from 7 First represent both as a binary number 7 is 0000 0111 (1 + 2 + 4) 3 is 0000 0011 (1 + 2) Reverse the 0s and 1s and then add 1 to get -3 0000 0011 reversed is 1111 1100 add 1 0000 0001 The result is 1111 1101 In 2’s Compliment positive number are represented as regular binary numbers. Negative numbers will always have the leftmost bit as 1. Positive numbers will always have the leftmost bit as 0. Georgia Institute of Technology

Add the Negative Number To subtract 3 from 7 Add -3 to 7 7 is 0000 0111 -3 is 1111 1101 The result is 1 0000 0100 Through away the leftmost 1 The answer is 0000 0100 which is 4 Georgia Institute of Technology

Georgia Institute of Technology Patterns Exercise How many different patterns of on and off bits are there in 3 bits? How many in 4 bits? How many in 8 bits? 000 is one pattern 001 is another pattern 010 is another pattern Georgia Institute of Technology

Does the number of patterns matter? Some garage door openers in the 70s used 8 bits to set the code to use to open the door Giving 256 different patterns Which is enough that you won’t open your neighbors door But small enough that someone could try each one The picture shows a garage door opener from the 90s with 12 bits. Georgia Institute of Technology

Georgia Institute of Technology Remote Entry Systems With 8 bits for a code you have a 1/256 chance of a random code working You don’t want someone opening your car in a place with lots of cars (like a mall) There are also radio scanners that can capture your code So you want the code to change each time Modern remote entry systems use a 40 bit rolling code See http://auto.howstuffworks.com/remote-entry2.htm for more information on remote entry systems. Georgia Institute of Technology

Georgia Institute of Technology Summary Computers store numbers using binary Not decimal Decimal numbers can be represented in binary Negative numbers are stored in 2’s compliment For n bits you have 2n patterns 3 bits is 8 patterns 4 bits is 16 patterns 8 bits is 256 patterns Computers are not terribly intelligent. They are basically advanced calculators. What makes them powerful is the encodings we use to assign meaning to their number manipulations and the speed at which they operate. Computers can actually only add. They subtract by adding a negative number. They multiply by doing several additions. They divide by doing several subtractions. Georgia Institute of Technology

Georgia Institute of Technology Vocabulary Exercise Look at two computer advertisements See if you can figure out what all the words mean Use the internet to look up unfamiliar words http://computer.howstuffworks.com/ http://en.wikipedia.org/ http://webopedia.com Which one is a better for computer games? Which one is better for your homework? Go to www.dell.com or www.gateway.com as two places to order computers. Georgia Institute of Technology

Georgia Institute of Technology Summary Numbers are stored using binary numbers Computers only know how to add They subtract by turning one number into a negative Using 2’s compliment The number of values you can store in n bits is 2n 3 bits gives 23 which is 2 * 2 * 2 or 8 4 bits gives 24 which is 2 * 2 * 2 * 2 or 16 8 bits gives 28 which is 256 values Computers have several kinds of memory With different speeds and cost Georgia Institute of Technology