# This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

Save this PDF as:

Size: px
Start display at page:

Download "This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers"

## Transcription

1 This Unit: Floating Point Arithmetic CIS 371 Computer Organization and Design Unit 7: Floating Point App App App System software Mem CPU I/O Formats Precision and range IEEE 754 standard Operations Addition and subtraction Multiplication and division Error analysis Error and bias Rounding and truncation CIS371 (Roth/Martin): Floating Point 1 CIS371 (Roth/Martin): Floating Point 2 Readings P+H Chapter 3.6 and 3.7 Floating Point (FP) Numbers Floating point numbers: numbers in scientific notation Two uses Use I: real numbers (numbers with non-zero fractions) * Use II: really big numbers 3.0 * * Aside: best not used for currency values CIS371 (Roth/Martin): Floating Point 3 CIS371 (Roth/Martin): Floating Point 4

2 The Land Before Floating Point Early computers were built for scientific calculations ENIAC: ballistic firing tables But didn t have primitive floating point data types Many embedded chips today lack floating point hardware Programmers built scale factors into programs Large constant multiplier turns all FP numbers to integers inputs multiplied by scale factor manually Outputs divided by scale factor manually Sometimes called fixed point arithmetic The Fixed Width Dilemma Natural arithmetic has infinite width Infinite number of integers Infinite number of reals Infinitely more reals than integers (head spinning ) Hardware arithmetic has finite width N (e.g., 16, 32, 64) Can represent 2 N numbers If you could represent 2 N integers, which would they be? Easy, the 2 N 1 on either size of 0 If you could represent 2 N reals, which would they be? 2 N reals from 0 to 1, not too useful Uhh. umm CIS371 (Roth/Martin): Floating Point 5 CIS371 (Roth/Martin): Floating Point 6 Range and Precision Range Distance between largest and smallest representable numbers Want big Precision Distance between two consecutive representable numbers Want small In fixed width, can t have unlimited both Scientific Notation Scientific notation: good compromise Number [S,F,E] = S * F * 2 E S: sign F: significand (fraction) E: exponent Floating point : binary (decimal) point has different magnitude + Sliding window of precision using notion of significant digits Small numbers very precise, many places after decimal point Big numbers are much less so, not all integers representable But for those instances you don t really care anyway Caveat: all representations are just approximations Sometimes wierdos like or come up + But good enough for most purposes CIS371 (Roth/Martin): Floating Point 7 CIS371 (Roth/Martin): Floating Point 8

3 IEEE 754 Standard Precision/Range Single precision: float in C 32-bit: 1-bit sign + 8-bit exponent + 23-bit significand Range: 2.0 * < N < 2.0 * Precision: ~7 significant (decimal) digits Used when exact precision is less important (e.g., 3D games) Double precision: double in C 64-bit: 1-bit sign + 11-bit exponent + 52-bit significand Range: 2.0 * < N < 2.0 * Precision: ~15 significant (decimal) digits Used for scientific computations Numbers > don t come up in many calculations ~ number of atoms in universe How Do Bits Represent Fractions? Sign: 0 or 1! easy Exponent: signed integer! also easy Significand: unsigned fraction!?? How do we represent integers? Sums of positive powers of two S-bit unsigned integer A: A S 1 2 S 1 + A S 2 2 S A A So how can we represent fractions? Sums of negative powers of two S-bit unsigned fraction A: A S A S A 1 2 S+2 + A 0 2 S+1 1, 1/2, 1/4, 1/8, 1/16, 1/32, More significant bits correspond to larger multipliers CIS371 (Roth/Martin): Floating Point 9 CIS371 (Roth/Martin): Floating Point 10 Some Examples What is 5 in floating point? Sign: 0 5 = 1.25 * 2 2 Significand: 1.25 = 1* *2 2 = Exponent: 2 = What is 0.5 in floating point? Sign: = 0.5 * 2 0 Significand: 0.5 = 1*2 1 = Exponent: 0 = Normalized Numbers Notice 5 is 1.25 * 2 2 But isn t it also * 2 3 and * 2 4 and? With 8-bit exponent, we can have 256 representations of 5 Multiple representations for one number Lead to computational errors Waste bits Solution: choose normal (canonical) form Disallow de-normalized numbers IEEE 754 normal form: coefficient of 2 0 is 1 Similar to scientific notation: one non-zero digit left of decimal Normalized representation of 5 is 1.25 * 2 2 (1.25 = 1*2 0 +1*2-2 ) * 2 3 is de-normalized (0.625 = 0*2 0 +1* *2-3 ) CIS371 (Roth/Martin): Floating Point 11 CIS371 (Roth/Martin): Floating Point 12

4 More About Normalization What is 0.5 in normalized floating point? Sign: = 1 * 2 1 Significand: 1 = 1*2 0 = Exponent: -1 = IEEE754: no need to represent co-efficient of 2 0 explicitly It s always 1 + Buy yourself an extra bit (~1/3 of decimal digit) of precision Yeeha Problem: what about 0? How can we represent 0 if 2 0 is always implicitly 1? IEEE 754: The Whole Story Exponent: signed integer! not so fast Exponent represented in excess or bias notation N-bits typically can represent signed numbers from 2 N 1 to 2 N 1 1 But in IEEE 754, they represent exponents from 2 N 1 +2 to 2 N 1 1 And they represent those as unsigned with an implicit 2 N 1 1 added Implicit added quantity is called the bias Actual exponent is E (2 N 1 1) Example: single precision (8-bit exponent) Bias is 127, exponent range is 126 to is represented as 1 = is represented as 254 = is represented as 127 = is represented as 128 = CIS371 (Roth/Martin): Floating Point 13 CIS371 (Roth/Martin): Floating Point 14 IEEE 754: Continued Notice: two exponent bit patterns are unused : represents de-normalized numbers Numbers that have implicit 0 (rather than 1) in 2 0 Zero is a special kind of de-normalized number + Exponent is all 0s, significand is all 0s (bzero still works) There are both +0 and 0, but they are considered the same Also represent numbers smaller than smallest normalized numbers : represents infinity and NaN ± infinities have 0s in the significand ± NaNs do not IEEE 754: Infinity and Beyond What are infinity and NaN used for? To allow operations to proceed past overflow/underflow situations Overflow: operation yields exponent greater than 2 N 1 1 Underflow: operation yields exponent less than 2 N 1 +2 IEEE 754 defines operations on infinity and NaN N / 0 = infinity N / infinity = 0 0 / 0 = NaN Infinity / infinity = NaN Infinity infinity = NaN Anything and NaN = NaN CIS371 (Roth/Martin): Floating Point 15 CIS371 (Roth/Martin): Floating Point 16

5 IEEE 754: Final Format exp significand Biased exponent Normalized significand Exponent more significant than significand Helps comparing FP numbers Exponent bias notation helps there too Every computer since about 1980 supports this standard Makes code portable (at the source level at least) Makes hardware faster (stand on each other s shoulders) Floating Point Arithmetic We will look at Addition/subtraction Multiplication/division Implementation Basically, integer arithmetic on significand and exponent Using integer ALUs Plus extra hardware for normalization To help us here, look at toy quarter precision format 8 bits: 1-bit sign + 3-bit exponent + 4-bit significand Bias is 3 CIS371 (Roth/Martin): Floating Point 17 CIS371 (Roth/Martin): Floating Point 18 FP Addition Assume A represented as bit pattern [S A, E A, F A ] B represented as bit pattern [S B, E B, F B ] What is the bit pattern for A+B [S A+B, E A+B, F A+B ]? [S A +S B, E A +E B, F A +F B ]? Of course not So what is it then? CIS371 (Roth/Martin): Floating Point 19 FP Addition Decimal Example Let s look at a decimal example first: * *10-1 Step I: align exponents (if necessary) Temporarily de-normalize one with smaller exponent Add 2 to exponent! shift significand right by 2 8.0* 10-1! 0.08*10 1 Step II: add significands Remember overflow, it isn t treated like integer overflow 9.95* *10 1! 10.03*10 1 Step III: normalize result Shift significand right by 1 add 1 to exponent 10.03*10 1! 1.003*10 2 CIS371 (Roth/Martin): Floating Point 20

7 FP Division Assume A represented as bit pattern [S A, E A, F A ] B represented as bit pattern [S B, E B, F B ] What is the bit pattern for A/B [S A/B, E A/B, F A/B ]? [S A^S B, E A E B, F A /F B ]? Pretty much, again except for Normalization Subtraction of exponents in biased notation (must add bias) Binary point placement No need to worry about remainders, either Ironic Multiplication/division roughly same complexity for FP and integer Addition/subtraction much more complicated for FP than integer CIS371 (Roth/Martin): Floating Point 25 Accuracy Remember our decimal addition example? 9.95* *10-1! 1.003*10 2 Extra decimal place caused by de-normalization But what if our representation only has two digits of precision? What happens to the 3? Corresponding binary question: what happens to extra 1s? Solution: round Option I: round down (truncate), no hardware necessary Option II: round up (round), need an incrementer Why rounding up called round? Because an extra 1 is half-way, which rounded up CIS371 (Roth/Martin): Floating Point 26 More About Accuracy Problem with both truncation and rounding They cause errors to accumulate E.g., if always round up, result will gradually crawl upwards One solution: round to nearest even If un-rounded LSB is 1! round up (011! 10) If un-rounded LSB is 0! round down (001! 00) Round up half the time, down other half! overall error is stable Another solution: multiple intermediate precision bits IEEE 754 defines 3: guard + round + sticky Guard and round are shifted by de-normalization as usual Sticky is 1 if any shifted out bits are 1 Round up if 101 or higher, round down if 011 or lower Round to nearest even if 100 Numerical Analysis Accuracy problems sometimes get bad Addition of big and small numbers Summing many small numbers Subtraction of big numbers Example, what s 1* *10 0 1*10 30? Intuitively: 1*10 0 = 1 But: (1* *10 0 ) 1*10 30 = (1* *10 30 ) = 0 Numerical analysis: field formed around this problem Bounding error of numerical algorithms Re-formulating algorithms in a way that bounds numerical error Practical hints: never test for equality between FP numbers Use something like: if(abs(a-b) < ) then CIS371 (Roth/Martin): Floating Point 27 CIS371 (Roth/Martin): Floating Point 28

8 One Last Thing About Accuracy Suppose you added two numbers and came up with What happens when you round? Number becomes denormalized arrrrgggghhh Arithmetic Latencies Latency in cycles of common arithmetic operations Source: Software Optimization Guide for AMD Family 10h Processors, Dec 2007 Intel Core 2 chips similar FP adder actually has more than three steps Align exponents Add/subtract significands Re-normalize Round Potentially re-normalize again Potentially round again Add/Subtract Multiply Divide Int to 40 Int to 87 Floating point divide faster than integer divide? Why? 1 5 Fp Fp CIS371 (Roth/Martin): Floating Point 29 CIS371 (Roth/Martin): Floating Point 30 Summary App App App System software Mem CPU I/O FP representation Scientific notation: S*F*2 E IEEE754 standard Representing fractions FP operations Addition/subtraction: harder than integer Multiplication/division: same as integer!! Accuracy problems Rounding and truncation Upshot: FP is painful Thank lucky stars P37X has no FP CIS371 (Roth/Martin): Floating Point 31

### Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Decimal Division Remember 4th grade long division? 43 // quotient 12 521 // divisor dividend -480 41-36 5 // remainder Shift divisor left (multiply by 10) until MSB lines up with dividend s Repeat until

### Restoring division. 2. Run the algorithm Let s do 0111/0010 (7/2) unsigned. 3. Find remainder here. 4. Find quotient here.

Binary division Dividend = divisor q quotient + remainder CS/COE447: Computer Organization and Assembly Language Given dividend and divisor, we want to obtain quotient (Q) and remainder (R) Chapter 3 We

### Computer Organization and Architecture

Computer Organization and Architecture Chapter 9 Computer Arithmetic Arithmetic & Logic Unit Performs arithmetic and logic operations on data everything that we think of as computing. Everything else in

### Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Divide: Paper & Pencil Computer Architecture ALU Design : Division and Floating Point 1001 Quotient Divisor 1000 1001010 Dividend 1000 10 101 1010 1000 10 (or Modulo result) See how big a number can be

### TECH. Arithmetic & Logic Unit. CH09 Computer Arithmetic. Number Systems. ALU Inputs and Outputs. Binary Number System

CH09 Computer Arithmetic CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer Representation Integer Arithmetic Floating-Point Representation

### comp 180 Lecture 21 Outline of Lecture Floating Point Addition Floating Point Multiplication HKUST 1 Computer Science

Outline of Lecture Floating Point Addition Floating Point Multiplication HKUST 1 Computer Science IEEE 754 floating-point standard In order to pack more bits into the significant, IEEE 754 makes the leading

### Chapter 4. Computer Arithmetic

Chapter 4 Computer Arithmetic 4.1 Number Systems A number system uses a specific radix (base). Radices that are power of 2 are widely used in digital systems. These radices include binary (base 2), quaternary

### ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

ECE 0142 Computer Organization Lecture 3 Floating Point Representations 1 Floating-point arithmetic We often incur floating-point programming. Floating point greatly simplifies working with large (e.g.,

### Floating-point computation

Real values and floating point values Floating-point representation IEEE 754 standard representation rounding special values Floating-point computation 1 Real values Not all values can be represented exactly

### Binary Representation and Computer Arithmetic

Binary Representation and Computer Arithmetic The decimal system of counting and keeping track of items was first created by Hindu mathematicians in India in A.D. 4. Since it involved the use of fingers

### quotient = dividend / divisor, with a remainder Given dividend and divisor, we want to obtain quotient (Q) and remainder (R)

Binary division quotient = dividend / divisor, with a remainder dividend = divisor quotient + remainder Given dividend and divisor, we want to obtain quotient (Q) and remainder (R) We will start from our

### After adjusting the expoent value of the smaller number have

1 (a) Provide the hexadecimal representation of a denormalized number in single precision IEEE 754 notation. What is the purpose of denormalized numbers? A denormalized number is a floating point number

### Integer and Real Numbers Representation in Microprocessor Techniques

Brno University of Technology Integer and Real Numbers Representation in Microprocessor Techniques Microprocessor Techniques and Embedded Systems Lecture 1 Dr. Tomas Fryza 30-Sep-2011 Contents Numerical

### Quiz for Chapter 3 Arithmetic for Computers 3.10

Date: Quiz for Chapter 3 Arithmetic for Computers 3.10 Not all questions are of equal difficulty. Please review the entire quiz first and then budget your time carefully. Name: Course: Solutions in RED

### ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

ECE 0142 Computer Organization Lecture 3 Floating Point Representations 1 Floating-point arithmetic We often incur floating-point programming. Floating point greatly simplifies working with large (e.g.,

### By the end of the lecture, you should be able to:

Extra Lecture: Number Systems Objectives - To understand: Base of number systems: decimal, binary, octal and hexadecimal Textual information stored as ASCII Binary addition/subtraction, multiplication

### Introduction to IEEE Standard 754 for Binary Floating-Point Arithmetic

Introduction to IEEE Standard 754 for Binary Floating-Point Arithmetic Computer Organization and Assembly Languages, NTU CSIE, 2004 Speaker: Jiun-Ren Lin Date: Oct 26, 2004 Floating point numbers Integers:

### Floating Point Numbers. Question. Learning Outcomes. Number Representation - recap. Do you have your laptop here?

Question Floating Point Numbers 6.626068 x 10-34 Do you have your laptop here? A yes B no C what s a laptop D where is here? E none of the above Eddie Edwards eedwards@doc.ic.ac.uk https://www.doc.ic.ac.uk/~eedwards/compsys

### Data Representation Binary Numbers

Data Representation Binary Numbers Integer Conversion Between Decimal and Binary Bases Task accomplished by Repeated division of decimal number by 2 (integer part of decimal number) Repeated multiplication

### Fractional Numbers. Fractional Number Notations. Fixed-point Notation. Fixed-point Notation

2 Fractional Numbers Fractional Number Notations 2010 - Claudio Fornaro Ver. 1.4 Fractional numbers have the form: xxxxxxxxx.yyyyyyyyy where the x es constitute the integer part of the value and the y

### Integer multiplication

Integer multiplication Suppose we have two unsigned integers, A and B, and we wish to compute their product. Let A be the multiplicand and B the multiplier: A n 1... A 1 A 0 multiplicand B n 1... B 1 B

### CPE 323 Data Types and Number Representations

CPE 323 Data Types and Number Representations Aleksandar Milenkovic Numeral Systems: Decimal, binary, hexadecimal, and octal We ordinarily represent numbers using decimal numeral system that has 10 as

### CHAPTER 5 Round-off errors

CHAPTER 5 Round-off errors In the two previous chapters we have seen how numbers can be represented in the binary numeral system and how this is the basis for representing numbers in computers. Since any

### Binary Number System. 16. Binary Numbers. Base 10 digits: 0 1 2 3 4 5 6 7 8 9. Base 2 digits: 0 1

Binary Number System 1 Base 10 digits: 0 1 2 3 4 5 6 7 8 9 Base 2 digits: 0 1 Recall that in base 10, the digits of a number are just coefficients of powers of the base (10): 417 = 4 * 10 2 + 1 * 10 1

### Number Systems and. Data Representation

Number Systems and Data Representation 1 Lecture Outline Number Systems Binary, Octal, Hexadecimal Representation of characters using codes Representation of Numbers Integer, Floating Point, Binary Coded

### Fixed-Point Arithmetic

Fixed-Point Arithmetic Fixed-Point Notation A K-bit fixed-point number can be interpreted as either: an integer (i.e., 20645) a fractional number (i.e., 0.75) 2 1 Integer Fixed-Point Representation N-bit

### Radix Number Systems. Number Systems. Number Systems 4/26/2010. basic idea of a radix number system how do we count:

Number Systems binary, octal, and hexadecimal numbers why used conversions, including to/from decimal negative binary numbers floating point numbers character codes basic idea of a radix number system

### Chapter II Binary Data Representation

Chapter II Binary Data Representation The atomic unit of data in computer systems is the bit, which is actually an acronym that stands for BInary digit. It can hold only 2 values or states: 0 or 1, true

### CHAPTER 2 Data Representation in Computer Systems

CHAPTER 2 Data Representation in Computer Systems 2.1 Introduction 47 2.2 Positional Numbering Systems 48 2.3 Converting Between Bases 48 2.3.1 Converting Unsigned Whole Numbers 49 2.3.2 Converting Fractions

### Bit operations carry* 0110 a 0111 b a+b. 1 and 3 exclusive OR (^) 2 and 4 and (&) 5 or ( )

Bit operations 1 and 3 exclusive OR (^) 2 and 4 and (&) 5 or ( ) 01100 carry* 0110 a 0111 b 01101 a+b * Always start with a carry-in of 0 Did it work? What is a? What is b? What is a+b? What if 8 bits

### Simulation & Synthesis Using VHDL

Floating Point Multipliers: Simulation & Synthesis Using VHDL By: Raj Kumar Singh - B.E. (Hons.) Electrical & Electronics Shivananda Reddy - B.E. (Hons.) Electrical & Electronics BITS, PILANI Outline Introduction

### 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

Exercises 1 - number representations Questions 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: (a) 3012 (b) - 435 2. For each of

### Recall that in base 10, the digits of a number are just coefficients of powers of the base (10):

Binary Number System 1 Base 10 digits: 0 1 2 3 4 5 6 7 8 9 Base 2 digits: 0 1 Recall that in base 10, the digits of a number are just coefficients of powers of the base (10): 417 = 4 * 10 2 + 1 * 10 1

### CALCULATOR AND COMPUTER ARITHMETIC

MathScope Handbook - Calc/Comp Arithmetic Page 1 of 7 Click here to return to the index 1 Introduction CALCULATOR AND COMPUTER ARITHMETIC Most of the computational work you will do as an Engineering Student

### CHAPTER THREE. 3.1 Binary Addition. Binary Math and Signed Representations

CHAPTER THREE Binary Math and Signed Representations Representing numbers with bits is one thing. Doing something with them is an entirely different matter. This chapter discusses some of the basic mathematical

### FLOATING POINT NUMBERS

FLOATING POINT NUMBERS Introduction Richard Hayden (with thanks to Naranker Dulay) rh@doc.ic.ac.uk http://www.doc.ic.ac.uk/~rh/teaching or https://www.doc.ic.ac.uk/~wl/teachlocal/arch1 or CATE Numbers:

### Presented By: Ms. Poonam Anand

Presented By: Ms. Poonam Anand Know the different types of numbers Describe positional notation Convert numbers in other bases to base 10 Convert base 10 numbers into numbers of other bases Describe the

### Integer Numbers. The Number Bases of Integers Textbook Chapter 3

Integer Numbers The Number Bases of Integers Textbook Chapter 3 Number Systems Unary, or marks: /////// = 7 /////// + ////// = ///////////// Grouping lead to Roman Numerals: VII + V = VVII = XII Better:

### Approximation Errors in Computer Arithmetic (Chapters 3 and 4)

Approximation Errors in Computer Arithmetic (Chapters 3 and 4) Outline: Positional notation binary representation of numbers Computer representation of integers Floating point representation IEEE standard

### Arithmetic Operations

Arithmetic Operations Dongbing Gu School of Computer Science and Electronic Engineering University of Essex UK Spring 2013 D. Gu (Univ. of Essex) Arithmetic Operations Spring 2013 1 / 34 Outline 1 Introduction

### MIPS floating-point arithmetic

MIPS floating-point arithmetic Floating-point computations are vital for many applications, but correct implementation of floating-point hardware and software is very tricky. Today we ll study the IEEE

### Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

ECE Department Summer LECTURE #5: Number Systems EEL : Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz Decimal Number System: -Our standard number system is base, also

### > 2. Error and Computer Arithmetic

> 2. Error and Computer Arithmetic Numerical analysis is concerned with how to solve a problem numerically, i.e., how to develop a sequence of numerical calculations to get a satisfactory answer. Part

### To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Binary Numbers In computer science we deal almost exclusively with binary numbers. it will be very helpful to memorize some binary constants and their decimal and English equivalents. By English equivalents

### Bits, Data Types, and Operations. University of Texas at Austin CS310H - Computer Organization Spring 2010 Don Fussell

Bits, Data Types, and Operations University of Texas at Austin CS3H - Computer Organization Spring 2 Don Fussell How do we represent data in a computer? At the lowest level, a computer is an electronic

### This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

Introduction to Embedded Microcomputer Systems Lecture 5.1 2.9. Conversions ASCII to binary n = 100*(Data[0]-0x30) + 10*(Data[1]-0x30) + (Data[2]-0x30); This 3-digit ASCII string could also be calculated

### Y = abc = a b c.2 0

Chapter 2 Bits, Data Types & Operations Integer Representation Floating-point Representation Other data types Why do Computers use Base 2? Base 10 Number Representation Natural representation for human

### Representation of Floating Point Numbers in

Representation of Floating Point Numbers in Single Precision IEEE 754 Standard Value = N = (-1) S X 2 E-127 X (1.M) 0 < E < 255 Actual exponent is: e = E - 127 sign 1 8 23 S E M exponent: excess 127 binary

### Computer arithmetic and round-off errors

Chapter 5 Computer arithmetic and round-off errors In the two previous chapters we have seen how numbers can be represented in the binary numeral system and how this is the basis for representing numbers

### Computer Science 281 Binary and Hexadecimal Review

Computer Science 281 Binary and Hexadecimal Review 1 The Binary Number System Computers store everything, both instructions and data, by using many, many transistors, each of which can be in one of two

### CSE 1400 Applied Discrete Mathematics Conversions Between Number Systems

CSE 400 Applied Discrete Mathematics Conversions Between Number Systems Department of Computer Sciences College of Engineering Florida Tech Fall 20 Conversion Algorithms: Decimal to Another Base Conversion

### Fixed-point Mathematics

Appendix A Fixed-point Mathematics In this appendix, we will introduce the notation and operations that we use for fixed-point mathematics. For some platforms, e.g., low-cost mobile phones, fixed-point

### COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about

### Measures of Error: for exact x and approximation x Absolute error e = x x. Relative error r = (x x )/x.

ERRORS and COMPUTER ARITHMETIC Types of Error in Numerical Calculations Initial Data Errors: from experiment, modeling, computer representation; problem dependent but need to know at beginning of calculation.

### Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Digital Logic 1 Data Representations 1.1 The Binary System The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer. The system we

### Binary Numbers. Binary Numbers. Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria

Binary Numbers Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria Wolfgang.Schreiner@risc.uni-linz.ac.at http://www.risc.uni-linz.ac.at/people/schreine

### Lecture 8: Binary Multiplication & Division

Lecture 8: Binary Multiplication & Division Today s topics: Addition/Subtraction Multiplication Division Reminder: get started early on assignment 3 1 2 s Complement Signed Numbers two = 0 ten 0001 two

### Representation of Data

Representation of Data In contrast with higher-level programming languages, C does not provide strong abstractions for representing data. Indeed, while languages like Racket has a rich notion of data type

### Number Systems & Encoding

Number Systems & Encoding Lecturer: Sri Parameswaran Author: Hui Annie Guo Modified: Sri Parameswaran Week2 1 Lecture overview Basics of computing with digital systems Binary numbers Floating point numbers

### Correctly Rounded Floating-point Binary-to-Decimal and Decimal-to-Binary Conversion Routines in Standard ML. By Prashanth Tilleti

Correctly Rounded Floating-point Binary-to-Decimal and Decimal-to-Binary Conversion Routines in Standard ML By Prashanth Tilleti Advisor Dr. Matthew Fluet Department of Computer Science B. Thomas Golisano

### Binary Numbers. Binary Numbers. Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria

Binary Numbers Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria Wolfgang.Schreiner@risc.uni-linz.ac.at http://www.risc.uni-linz.ac.at/people/schreine

### Number Representation

Number Representation Number System :: The Basics We are accustomed to using the so-called decimal number system Ten digits ::,,,3,4,5,6,7,8,9 Every digit position has a weight which is a power of Base

### Decimal Numbers: Base 10 Integer Numbers & Arithmetic

Decimal Numbers: Base 10 Integer Numbers & Arithmetic Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 )+(1x10 0 ) Ward 1 Ward 2 Numbers: positional notation Number

### Computer is a binary digital system. Data. Unsigned Integers (cont.) Unsigned Integers. Binary (base two) system: Has two states: 0 and 1

Computer Programming Programming Language Is telling the computer how to do something Wikipedia Definition: Applies specific programming languages to solve specific computational problems with solutions

### CS321. Introduction to Numerical Methods

CS3 Introduction to Numerical Methods Lecture Number Representations and Errors Professor Jun Zhang Department of Computer Science University of Kentucky Lexington, KY 40506-0633 August 7, 05 Number in

### Chapter 2: Number Systems

Chapter 2: Number Systems Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This two-valued number system is called binary. As presented earlier, there are many

### Numerical Matrix Analysis

Numerical Matrix Analysis Lecture Notes #10 Conditioning and / Peter Blomgren, blomgren.peter@gmail.com Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences Research

### Arithmetic Processing. Basic Fixed Point NRS. Number Representation. Digit Values. Rule of Interpretation CS/EE 5830/6830 VLSI ARCHITECTURE

CS/EE 5830/6830 VLSI ARCHITECTURE Chapter 1 Basic Number Representations and Arithmetic Algorithms Arithmetic Processing AP = (operands, operation, results, conditions, singularities) Operands are: Set

### 4 Operations On Data

4 Operations On Data 4.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, students should be able to: List the three categories of operations performed on

### Programming Challenges

Programming Challenges Week 4 - Arithmetic and Algebra Claus Aranha caranha@cs.tsukuba.ac.jp College of Information Sciences May 11, 2014 Some Quick Notes (1) ICPC Programming Contest 2014 Website: http://icpc.iisf.or.jp/2014-waseda/

### ELET 7404 Embedded & Real Time Operating Systems. Fixed-Point Math. Chap. 9, Labrosse Book. Fall 2007

ELET 7404 Embedded & Real Time Operating Systems Fixed-Point Math Chap. 9, Labrosse Book Fall 2007 Fixed-Point Math Most low-end processors, such as embedded processors Do not provide hardware-assisted

### 2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

2/9/9 Binary number system Computer (electronic) systems prefer binary numbers Binary number: represent a number in base-2 Binary numbers 2 3 + 7 + 5 Some terminology Bit: a binary digit ( or ) Hexadecimal

### Fixed-Point Numbers. Positional representation: k whole and l fractional digits. x x 1. x k 2. . x 1

Fied-Point Numbers Positional representation: k whole and l fractional digits Value of a number: = ( k 1 k 2... 1 0. 1 2... l ) r = Σ i r i For eample: 2.375 = (10.011) two = (1 2 1 ) + (0 2 0 ) + (0 2

### Introduction Number Systems and Conversion

UNIT 1 Introduction Number Systems and Conversion Objectives 1. Introduction The first part of this unit introduces the material to be studied later. In addition to getting an overview of the material

### Data types. lecture 4

Data types lecture 4 Information in digital computers is represented using binary number system. The base, i.e. radix, of the binary system is 2. Other common number systems: octal (base 8), decimal (base

### Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Digital Arithmetic Digital Arithmetic: Operations and Circuits Dr. Farahmand Binary Arithmetic Digital circuits are frequently used for arithmetic operations Fundamental arithmetic operations on binary

### Introduction to Telecommunications and Computer Engineering Unit 2: Number Systems and Logic

Introduction to Telecommunications and Computer Engineering Unit 2: Number Systems and Logic Syedur Rahman Lecturer, CSE Department North South University syedur.rahman@wolfson.oon.org Acknowledgements

### Verilog Review and Fixed Point Arithmetics. Overview

Verilog Review and Fixed Point Arithmetics CSE4210 Winter 2012 Mokhtar Aboelaze based on slides by Dr. Shoab A. Khan Overview Floating and Fixed Point Arithmetic System Design Flow Requirements and Specifications

### 2.1 Binary Numbers. 2.3 Number System Conversion. From Binary to Decimal. From Decimal to Binary. Section 2 Binary Number System Page 1 of 8

Section Binary Number System Page 1 of 8.1 Binary Numbers The number system we use is a positional number system meaning that the position of each digit has an associated weight. The value of a given number

### Lecture 2. Binary and Hexadecimal Numbers

Lecture 2 Binary and Hexadecimal Numbers Purpose: Review binary and hexadecimal number representations Convert directly from one base to another base Review addition and subtraction in binary representations

### 1. Convert the following binary exponential expressions to their 'English'

Answers to Practice Problems Practice Problems - Integer Number System Conversions 1. Convert the decimal integer 427 10 into the following number systems: a. 110101011 2 c. 653 8 b. 120211 3 d. 1AB 16

### Floating Point Arithmetic. Fractional Binary Numbers. Floating Point. Page 1. Numbers

Floating Point Arithmetic Topics Numbers in general IEEE Floating Point Standard Rounding Floating Point Mathematical properties Puzzles test basic understanding Bizarre FP factoids Numbers Many types

### Two s Complement Arithmetic

Two s Complement Arithmetic We now address the issue of representing integers as binary strings in a computer. There are four formats that have been used in the past; only one is of interest to us. The

### Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Today Binary addition Representing negative numbers 2 Binary Addition Consider the following binary numbers: 0 0 1 0 0 1 1 0 0 0 1 0 1 0 1 1 How do we add these numbers? 3 Binary Addition 0 0 1 0 0 1 1

### Here 4 is the least significant digit (LSD) and 2 is the most significant digit (MSD).

Number System Introduction Number systems provide the basis for all operations in information processing systems. In a number system the information is divided into a group of symbols; for example, 26

### Chapter 2 Numeric Representation.

Chapter 2 Numeric Representation. Most of the things we encounter in the world around us are analog; they don t just take on one of two values. How then can they be represented digitally? The key is that

### CS201: Architecture and Assembly Language

CS201: Architecture and Assembly Language Lecture Three Brendan Burns CS201: Lecture Three p.1/27 Arithmetic for computers Previously we saw how we could represent unsigned numbers in binary and how binary

### COMPUTER ARCHITECTURE IT0205

COMPUTER ARCHITECTURE IT0205 M.Thenmozhi/Kayalvizhi Jayavel/M.B.Panbu Asst.Prof.(Sr.G)/Asst.Prof.(Sr.G)/Asst.Prof.(O.G) Department of IT SRM University, Kattankulathur 1 Disclaimer The contents of the

### A Library of Parameterized Floating Point Modules and Their Use

A Library of Parameterized Floating Point Modules and Their Use Pavle Belanović and Miriam Leeser Dept of Electrical and Computer Engineering Northeastern University Boston, MA, 02115, USA {pbelanov,mel}@ece.neu.edu

### Floating-Point Numbers. Floating-point number system characterized by four integers: base or radix precision exponent range

Floating-Point Numbers Floating-point number system characterized by four integers: β p [L, U] base or radix precision exponent range Number x represented as where x = ± ( d 0 + d 1 β + d 2 β 2 + + d p

### 198:211 Computer Architecture

198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book 1 Computer Architecture What do computers do? Manipulate stored

### 1. Number Representation

CSEE 3827: Fundamentals of Computer Systems, Spring 2011 1. Number Representation Prof. Martha Kim (martha@cs.columbia.edu) Web: http://www.cs.columbia.edu/~martha/courses/3827/sp11/ Contents (H&H 1.3-1.4,

### Binary Numbers Again. Binary Arithmetic, Subtraction. Binary, Decimal addition

Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N -1. 4 bits = 0 to 15 8 bits = 0 to 255 16 bits = 0 to 65535 Besides simply representation, we would

### CSCI 230 Class Notes Binary Number Representations and Arithmetic

CSCI 230 Class otes Binary umber Representations and Arithmetic Mihran Tuceryan with some modifications by Snehasis Mukhopadhyay Jan 22, 1999 1 Decimal otation What does it mean when we write 495? How

### Arithmetic in MIPS. Objectives. Instruction. Integer arithmetic. After completing this lab you will:

6 Objectives After completing this lab you will: know how to do integer arithmetic in MIPS know how to do floating point arithmetic in MIPS know about conversion from integer to floating point and from

### CPS311 Lecture: Representing Information in Binary Last revised 8/22/13

CPS311 Lecture: Representing Information in Binary Last revised 8/22/13 Objectives: 1. To review binary representation for unsigned integers 2. To introduce octal and hexadecimal shorthands 3. To review

### Arithmetic Circuits Addition, Subtraction, & Multiplication

Arithmetic Circuits Addition, Subtraction, & Multiplication The adder is another classic design example which we are obliged look at. Simple decimal arithmetic is something which we rarely give a second

### The Essentials of Computer Organization and Architecture. Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003

The Essentials of Computer Organization and Architecture Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003 Chapter 2 Instructor's Manual Chapter Objectives Chapter 2, Data Representation,