ITEC 352 Lecture 7 Binary(2). Review Homework due on Friday Questions Binary Addition Subtraction Encoding.

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

CENG536 Computer Engineering department Çankaya University.
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
Assembly Language and Computer Architecture Using C++ and Java
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Computer Science 210 Computer Organization Floating Point Representation.
Lecture 8 Floating point format
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Number Systems Lecture 02.
Binary Representation and Computer Arithmetic
Simple Data Type Representation and conversion of numbers
Information Representation (Level ISA3) Floating point numbers.
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.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 22, 2004 Lecture Number: 24.
Number Systems So far we have studied the following integer number systems in computer Unsigned numbers Sign/magnitude numbers Two’s complement numbers.
Computing Systems Basic arithmetic for computers.
Computer Architecture
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
College of Engineering Representing Numbers in a Computer Section B, Spring 2003 COE1361: Computing for Engineers COE1361: Computing for Engineers 1 COE1361:
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Data Representation in Computer Systems
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
9.4 FLOATING-POINT REPRESENTATION
CSC 221 Computer Organization and Assembly Language
Integer and Fixed Point P & H: Chapter 3
CSPP58001 Floating Point Numbers. CSPP58001 Floating vs. fixed point Floating point refers to a binary decimal representation where there is not a fixed.
Computer Organization and Design Information Encoding II Montek Singh Wed, Aug 29, 2012 Lecture 3.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
1 Information Representation in Computer Lecture Nine.
Monday, January 14 Homework #1 is posted on the website Homework #1 is posted on the website Due before class, Jan. 16 Due before class, Jan. 16.
IT11004: Data Representation and Organization Floating Point Representation.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Computer Science 210 Computer Organization
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Dr. Clincy Professor of CS
Introduction To Computer Science
Floating Point Number system corresponding to the decimal notation
CS 232: Computer Architecture II
Data Structures Mohammed Thajeel To the second year students
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
Computer Science 210 Computer Organization
Dr. Clincy Professor of CS
Dr. Clincy Professor of CS
ECEG-3202 Computer Architecture and Organization
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
COMS 161 Introduction to Computing
IT11004: Data Representation and Organization
Presentation transcript:

ITEC 352 Lecture 7 Binary(2)

Review Homework due on Friday Questions Binary Addition Subtraction Encoding

Binary (2) Outline Two’s complement Excess notation Floating point format

Binary (2) Two’s complement Similar to one’s complement Solves issues –No double 0 –Addition / subtraction are the same Small conversion cost –Copy all 0’s from right to left –Copy first one –Flip all other bits

Binary (2) Class discussion Represent the following in one’s complement and 2’s complement:

Binary (2) Excess Representation Which one of the following two numbers represented in 1’s complement is greater? 1011 (or) 0100 What are the steps you had to go through to figure this out? We can avoid these steps by using an excess representation.

Binary (2) Excess representatio n Key idea: Make all negative numbers positive by shifting them up …. E.g., Suppose we want to represent numbers from -4 to +3. How do we make all negative numbers positive but at the same time preserving the difference in magnitudes between 2 numbers? We could do this by adding “+4” to all the numbers. Therefore, -4 becomes 0 -3 becomes 1 … 0 becomes 4 … 3 becomes 7 Because we shifted the numbers by 4, we call this Excess 4 representation

Binary (2) Excess Representatio n How does this help? Well consider, the question we asked earlier: Which one of the following two numbers is greater? 0000 or 0011 ? “0000” in Excess 4 representation is is -1. Comparing numbers becomes easier when Excess notation is used.

Binary (2) Excessiven ess The “bias” or “excess” (e.g., 4 in the previous slide) can be any number. Usually the bias is the smallest number that we would like to represent. E.g., if we want to represent numbers from -128 to +127, we will use Excess 128 representation. Because we need to consider “0”, we are stopping at 127 and not 128.

Binary (2) SUMMARY: Representing negative numbers in a 3 bit architecture (example)

Binary (2) Real numbers Numbers of the form: Contain a fractional part. Why even bother with real numbers? Isn’t this some esoteric stuff that is never used??

Binary (2) Rationale Floating point computations are everywhere –more common than simple integer computations. Examples: –Any engineering discipline: e.g., Construction industry –Computer security (e.g., random number generation) –Computer games (several graphical computations) Closer to reality: –My experience: NUMBER 1 reason why student programs don’t work in Programming contests!!

Binary (2) Real number problem How to store infinitely many floating point numbers into a finite number of bits. Consider a 34 digit binary number: How can we store this in a computer whose bus width is 32?

Binary (2) Real number Numbers Consider a 34 digit binary number: How can we store this in a computer whose bus width is 32? Option 1: Split it into two parts (2 X 32-bit integers). Problem: Slows handling of arithmetic operations. Why? Option 2: Sacrifice some precision. This is the idea behind a real number representation called floating point numbers Can you come up with your own standard?

Binary (2) Standards Come up with a standard such that the numbers: Can be represented within 4 bits. Can your standard now represent:

Binary (2) Real numbers A common way of representing real numbers is using “floating point numbers”. E.g., –real number: –Floating point number representations: * 10 2, or * 10 1, or * 10 3

Binary (2) Floating point –A real number: can have many Floating point number representations: * 10 2, or * 10 1, or * 10 3 To standardize the position of the floating point – it is normally represented as: – * 10 2 (only one digit to the left of the floating point).

Binary (2) Examples Normalize the following numbers in base 10: How about in base 2:

Binary (2) Base 10 More terms: Precision: number of digits in the significand -- sometimes fractions are too large – we need to approximate. The precision tells us by how much. Range: Number of digits in the exponent. Example Consider the number: if precision is 4 and range is 2 then this number is represented as: +(6.023 X ):

Binary (2) Base 2 Floating Point Consider the binary numbers: What is their normalized representation if precision = 4 and range = 2? Do you see any error?

Binary (2) Base 2 Floating Point Numbers Consider the binary numbers: What is their representation if precision = 4 and range = 2? Do you see any error? Error is called the rounding error. Every programming language suffers from this.

Binary (2) How to live with error. Floating point computations result in rounding errors (precision errors). However, the key is: be consistent with errors. For this, every language/architecture must follow one standard (so that the error is repeatable). –Most famous standard = IEEE 754 standard

Binary (2) Summary Two’s complement Excess notation Buildup to floating point numbers