Georgia Institute of Technology Introduction to Programming Part 3 Barb Ericson Georgia Institute of Technology May 2006.

Slides:



Advertisements
Similar presentations
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Advertisements

EMB1006 The Binary System There is no 2 Jonathan-Lee Jones.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Floating Point Numbers
Signed Numbers.
Floating Point Numbers
Representing Real Numbers Using Floating Point Notation Lecture 6 CSCI 1405, CSCI 1301 Introduction to Computer Science Fall 2009.
Signed Numbers CS208. Signed Numbers Until now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers.
Computer Science 210 Computer Organization Floating Point Representation.
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
Lecture 8 Floating point format
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
Binary Representation and Computer Arithmetic
Convert Decimal to Floating point number [IEEE 754]
01- Intro-Java-part1 1 Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology June 2008.
Simple Data Type Representation and conversion of numbers
Abstraction – Number Systems and Data Representation.
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Factional Values What is 0.75 in binary?. How could we represent fractions? In decimal: – As fractions : 1/5.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Georgia Institute of Technology Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology Aug 2005.
Computer Science 111 Fundamentals of Programming I Number Systems.
Binary Arithmetic & Data representation
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Chapter 2 Binary Values and Number Systems. 2 2 Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645,
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Chapter 3 Number Representation. Convert a number from decimal to binary notation and vice versa. Understand the different representations of an integer.
Number Representation
ITEC 1011 Introduction to Information Technologies 4. Floating Point Numbers Chapt. 5.
Introduction to Number System
CSPP58001 Floating Point Numbers. CSPP58001 Floating vs. fixed point Floating point refers to a binary decimal representation where there is not a fixed.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Floating Point in Binary 1.Place Value Chart:
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.
Floating Point Numbers
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.7 Instructor: Lin Chen Sept 2013.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Learning Objectives 3.3.1f - Describe the nature and uses of floating point form 3.3.1h - Convert a real number to floating point form Learn how to normalise.
Software Design and Development Storing Data Computing Science.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Floating Point Numbers
Nat 4/5 Computing Science Lesson 1: Binary
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Introduction To Computer Science
Numbers in a Computer Unsigned integers Signed magnitude
Floating Point Number system corresponding to the decimal notation
Introduction to Programming Part 3
Data Representation Data Types Complements Fixed Point Representation
Introduction to Java, and DrJava part 1
Unit 18: Computational Thinking
Number Representation
Computer Organization
Starter Using the fingers on only one hand, what is the highest number you can count to? Rules: You must start at 1 You must count sequentially (i.e.
CPS120: Introduction to Computer Science
Introduction to Java, and DrJava
Introduction to Programming Part 3
Abstraction – Number Systems and Data Representation
COMS 161 Introduction to Computing
Introduction to Java, and DrJava
Introduction to Java, and DrJava part 1
Data Binary Arithmetic.
Numbers with fractions Could be done in pure binary
OBJECTIVES After reading this chapter, the reader should be able to :
靜夜思 床前明月光, 疑是地上霜。 舉頭望明月, 低頭思故鄉。 ~ 李白 李商隱.
1.6) Storing Integer: 1.7) storing fraction:
Presentation transcript:

Georgia Institute of Technology Introduction to Programming Part 3 Barb Ericson Georgia Institute of Technology May 2006

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 to represent floating point numbers in binary –How many patterns do you have with n number of bits? Why does it matter?

Georgia Institute of Technology Binary Numbers We usually work with decimal numbers with digits from 0 to 9 and powers of = (7 * * * * 1) Or (7 * * * * 10 0 ) The binary number system uses digits 0 and 1 and powers of = (0 * * * * 1) Or (0 * * * *2 0 ) = 5

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 –1 + 1 = 0 with a carry of 1 into the next column to the left

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

Georgia Institute of Technology 2’s Compliment Example To subtract 3 from 7 First represent both as a binary number –7 is ( ) –3 is (1 + 2) Reverse the 0s and 1s and then add 1 to get -3 – reversed is – add –The result is

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

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

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

Georgia Institute of Technology Decimal Number Storage How do you think a computer stores: ? –It uses an IEEE 754 format –Converts the number into a value between 0 and 1 raised to a power of 2 –Stores 3 things A bit for the sign A number between 0 and 1 (the mantissa) The power of 2 (the exponent)

Georgia Institute of Technology Number of Bits Exercise How many bits would you need to represent 64 values? How many bits would you need to represent 256 values? How many bits would you need to represent 1024 values? How many bits would you need to represent 4096 values? How many bits would you need to represent 1 million values?

Georgia Institute of Technology Summary Numbers are stored using binary numbers –Integers are stored in 2’s compliment –Decimal numbers are stored in an IEEE format 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 2 n –3 bits gives 2 3 which is 2 * 2 * 2 or 8 –4 bits gives 2 4 which is 2 * 2 * 2 * 2 or 16 –8 bits gives 2 8 which is 256 values