Integers in 2’s compliment Floating point

Slides:



Advertisements
Similar presentations
Scientific Notations - Operations Addition and Subtraction 1 st Convert one of the numbers so the exponents match 2 nd Add or subtract the decimal numbers.
Advertisements

Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Booth’s Algorithm.
ECEN 248 Integer Multiplication, Number Format Adopted from Copyright 2002 David H. Albonesi and the University of Rochester.
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
Scientific Notation. Essential Question  How do I use scientific notation to represent numbers?
The Binary Number System
PERFORMING CALCULATIONS IN SCIENTIFIC NOTATION
 To add numbers in scientific notation: 1) Add the constants 2) Keep the exponent the same  Example: (2.1 x 10 5 ) + (3.2 x 10 5 ) = ( ) x 10.
Simple Data Type Representation and conversion of numbers
Data Representation – Binary Numbers
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Computer Arithmetic Nizamettin AYDIN
Factional Values What is 0.75 in binary?. How could we represent fractions? In decimal: – As fractions : 1/5.
Calculating with Significant Figures
1. Scientific Notation Every positive number X can be written as:
Intro to Chemistry. Scientific Notation Review your handout from before 10 = 1 x = 1 X 10 3 = 10 x 10 x 10.1 = = 1/10.01 = = 1/100.
Operations on Scientific Notation Addition and Subtraction 1. If they have the same exponent - add/subtract the number in front - keep the same exponent.
Operations with Scientific Notation. Addition and Subtraction Format Addition (N * 10 x ) + (M * 10 x ) = (N + M) * 10 x Subtraction (N * 10 y ) - (M.
Introduction to Number System
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Fractions in Binary.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Floating Point in Binary 1.Place Value Chart:
Scientific notation. What is scientific notation?  Numbers are written in the form M × 10 ^n, Where the factor M is a number greater than or equal to.
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.
Introduction To Number Systems Binary System M. AL-Towaileb1.
Rounding  We need to round numbers because a calculator often gives an answer with more digits than are justified by the precision of the measurements.
Exponents And how they make life easier! Exponents Exponents are used to write numbers in scientific notation. Exponents are powers of ten. 10 x 10 =
SCIENTIFIC NOTATION RULES. Rules for converting to Scientific Notation One non-zero number before the decimal One digit after the decimal If you are making.
Lecture 6: Floating Point Number Representation Information Representation: Floating Point Number Representation Lecture # 7.
Scientific Notation. What is Scientific Notation? Scientific notation is a way of writing extremely large or small measurements. The number is written.
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.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Floating Point Representations
Scientific Notation Objective: Students will be able to convert between scientific notation and regular notation and solve problems involving scientific.
PERFORMING CALCULATIONS IN SCIENTIFIC NOTATION
Number Systems and Binary Arithmetic
Integer Division.
Lecture 9: Floating Point
Math & Exponents.
Floating Point Number system corresponding to the decimal notation
Quantitative Measurements
REALLY BIG & REALLY small Numbers
William Stallings Computer Organization and Architecture 7th Edition
Scientific Notation Scientific notation takes the form: M x 10n
CSCE 350 Computer Architecture
CSCI206 - Computer Organization & Programming
SCIENTIFIC NOTATION.
How to represent real numbers
How to represent real numbers
ECEG-3202 Computer Architecture and Organization
12/7/
Rules for Determining Significant Figures
Multiply & Divide with Scientific Notation
Chapter 8 Computer Arithmetic
Multiplying and Dividing in Scientific Notation
PERFORMING CALCULATIONS IN SCIENTIFIC NOTATION
PERFORMING CALCULATIONS IN SCIENTIFIC NOTATION
Introduction To Number Systems
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

Integers in 2’s compliment Floating point Multiply and Divide Integers in 2’s compliment Floating point

Multiplying in Decimal 214  2.14 x 10 2 x 21  2.1 x 10 1 ------- multiply mantissa 214 add exponents + 4280 -------- ----------------- 4494  4.494 x 10 3

Multiplying in binary 1011 11 x 1110 x 14 ------- ------- 0000 44 1011 ----------- ------------ 10011010 154

History of binary multiplication Until late 1970’s most processors did not have a multiply instruction. Programs that repeated shifted and added were used instead. When much more transistors per chip became available, enough adders could be put on a single chip to um all the partial products at once. Rather than reuse a single adder repeatedly.

2 by 2 multiplication chip

4 by 4 multiplication chip

Multiplying floating point numbers sign exp fraction 0 1001 010  1.01 x 2 2 0 0111 110  1.11 x 2 0 ------------ 10.0011 x 2 2 Convert from 2’s compliment to scientific notation - create mantissa by putting a 1 to the left of fraction - subtract bias (7) from the exponents Multiple mantissas Add exponents Adjust exponent so mantissa starts 1.xxxx Add bias to exponent Fraction is the significant bits of mantissa without the leading 1 XOR signs 0 1010 000

Multiplying floating point numbers sign exp fraction 0 1001 010  1.01 x 2 2  5.000 0 0111 110  1.11 x 2 0  * 1.75 ----------------------- ------------ ----------- 0 1010 000  10.0011 x 2 2  8.75 In this example, just to make a point, the fraction only has 3 binary digits so we can only record 1.000 x 2 3 as the answer which is 8.00 not 8.75

Division in decimal and binary 5.25 4 21.00 20 ------ 1.0 .8 ------- .20 -------- 0 101.01 100 10101.00 100 ------ 101 ------- --------

Dividing floating point numbers sign exp fraction 0 1001 0000  +4  1.0000 x 2 (9−7) 0 1101 0101  +21  1.0101 x 2 (11−7) ------------------------------- 21/4 = 1.01010 x 2 2 Convert from 2’s compliment to scientific notation - create mantissa by putting a 1 to the left of fraction - subtract bias (7) from the exponents Divide mantissas Subtract exponents Adjust exponent so mantissa starts 1.xxxx Add bias to exponent Fraction is the significant bits of mantissa without the leading 1 XOR signs 0 1010 000

Dividing floating point numbers sign exp fraction 0 1011 0101  1.0101 x 2 0  21.00 0 1001 0000  1.00 x 2 2  ÷ 4.00 ----------------------- ------------ ----------- 0 1001 0101  1.0101 x 2 2  5.25 In this example, just to make a point, the fraction only has 4 binary digits so we can record precisely 1.0101 x 2 2 as the answer which is 5.25

Appendix A-1: Booth’s Algorithm If we are going to multiply A*63 +63  0011 1111 which would require 6 shift/adds Isn’t 63 = (64 – 1)? So instead of A*63, we will do A*(64-1) +64  0100 0000 So we do 1 add and 1 subtract (add 2’s compliment) instead of 6 adds.

Appendix A-2: Booth’s Algorithm +63  0011 1111 but isn’t 63 = (64 – 1)? +7  0000 0111 but isn’t 7 = (8 – 1)? 63 – 7 = 0011 1111 – 000 0111 = 0011 1000 = 56 But isn’t 56 = (63 – 7) = (64 – 1) – (8 – 1) = 64 – 8?

Appendix B: Multiply Overflow? Suppose you multiplied 2 signed positive 8 bit numbers? 0001 0000 * 0001 0000 = 1 0000 0000 (overflow) If both numbers have a bit on in the upper half, then there will be an overflow so there is no point in doing the multiplication. Therefore at least 1 number must have it’s upper half bits all set to 0.

Appendix C: worst cast shift/adds When multiplying 2-N bit positive numbers, at least 1 number must have it N/2 most significant bits = 0 What is the worst case of the number of shift/adds? N/2? Or less? (recall Booth’s algorithm can do N/2 consecutive 1’s with just 2 operations? When multiplying 2-N bit positive numbers, at least 1 number must have it? The worst case is the lesser of straight multiplying vs. Booth’s