Chapter 3. Arithmetic for Computers

Size: px
Start display at page:

Download "Chapter 3. Arithmetic for Computers"

Transcription

1 Chapter 3 Arithmetic for Computers

2 Arithmetic for Computers Unsigned vs. Signed Integers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation and operations 3.1 Int roduction Chapter 3 Arithmetic for Computers 2

3 Unsigned Binary Integers Given an n-bit number x = x + n 1 n n 12 + xn 22 + L+ x12 x02 Range: 0 to +2 n 1 Example 2.4 Sig gned and Unsigne ed Numb bers = = = Using 32 bits 0 to +4,294,967,295 Chapter 3 Arithmetic for Computers 3

4 Review: 2 s Complement Binary Representation Negate 1011 and add a complement all the bits Note: negate and invert are different! -2 3 = -(2 3-1) = = 2 sc binary decimal Chapter 3 Arithmetic for Computers 4

5 2s-Complement Signed Integers Given an n-bit number x = x + n 1 n n 12 + xn 22 + L+ x12 x02 Range: 2 n 1 to +2 n 1 1 Example = = 2,147,483, ,147,483,644 = 4 10 Using 32 bits 2,147,483,648 to +2,147,483,647 Chapter 3 Arithmetic for Computers 5

6 2s-Complement Signed Integers Bit 31 is sign bit 1f for negative numbers 0 for non-negative numbers ( 2 n 1 ) can t be represented Non-negative numbers have the same unsigned and 2s-complement representation Some specific numbers 0: : Most-negative: Most-positive: Chapter 3 Arithmetic for Computers 6

7 MIPS Number Representations 32-bit signed numbers (2 s complement): two = 0 ten two = + 1 ten... maxint MSB two = + 2,147,483,646,, ten two = + 2,147,483,647 ten two = 2,147,483,648 ten two = 2,147,483,647 ten two = 2 minint ten two = 1 ten LSB Converting <32-bit values into 32-bit values copy the most significant bit (the sign bit) into the empty bits > > sign extend versus zero extend (lb vs. lbu) Chapter 3 Arithmetic for Computers 7

8 Signed Negation Complement and add 1 Complement means 1 0, 0 1 x + x = = 1 x + 1= x Example: negate = = = Chapter 3 Arithmetic for Computers 8

9 Sign Extension Representing a number using more bits Preserve the numeric value In ARM instruction set LDRSB,LDRSH: extend loaded byte/halfword Replicate the sign bit to the left c.f. unsigned values: extend with 0s Examples: 8-bit to 16-bit +2: => : => Chapter 3 Arithmetic for Computers 9

10 Integer Addition Example: Ad dition and Subtraction Overflow if result out of range Adding +ve and ve operands, no overflow Adding two +ve operands Overflow if result sign is 1 Adding two ve operands Overflow if result sign is 0 Chapter 3 Arithmetic for Computers 10

11 Integer Subtraction Add negation of second operand Example: 7 6 = 7 + ( 6) +7: : : Overflow if result out of range Subtracting two +ve or two ve operands, no overflow Subtracting +ve from ve operand Overflow if result sign is 0 Subtracting ve from +ve operand Overflow if result sign is 1 Chapter 3 Arithmetic for Computers 11

12 Dealing with Overflow Some languages (e.g., C) ignore overflow Use ARM ADD,SUB instructions Other languages (e.g., Ada, Fortran) require raising an exception Use ARM ADDS,SUBS instructions On overflow, invoke exception handler Chapter 3 Arithmetic for Computers 12

13 Arithmetic for Multimedia Graphics and media processing operates on vectors of 8-bit and 16-bit data Use 64-bit adder, with partitioned carry chain Operate on 8 8-bit, 4 16-bit, or 2 32-bit vectors SIMD (single-instruction, multiple-data) Saturating operations On overflow, result is largest representable value c.f. 2s-complement modulo arithmetic E.g., clipping in audio, saturation in video Chapter 3 Arithmetic for Computers 13

14 Multiplication Start with long-multiplication approach 3.3 Mu ultiplicatio on multiplicand 1000 multiplier product Length of product is the sum of operand lengths Chapter 3 Arithmetic for Computers 14

15 Multiplication Hardware Initially 0 Chapter 3 Arithmetic for Computers 15

16 Optimized Multiplier Perform steps in parallel: add/shift One cycle per partial-product addition That s ok, if frequency of multiplications is low Chapter 3 Arithmetic for Computers 16

17 Faster Multiplier Uses multiple adders Cost/performance tradeoff Can be pipelined Several multiplication performed in parallel Chapter 3 Arithmetic for Computers 17

18 ARM Multiplication The MUL instruction is used to multiply signed or unsigned variables to produce a 32-bit result Instruction MUL Rd,Rm,Rs ; Rd = Rm * Rs (32 bits) Because the MUL instruction produces only the lower 32 bits of the 64-bit product, MUL gives the same answer for both signed and unsigned numbers Chapter 3 Arithmetic for Computers 18

19 Division divisor quotient dividend remainder n-bit operands yield n-bit quotient and remainder Check for 0 divisor Long division approach If divisor dividend bits 1 bit in quotient, subtract Otherwise 0 bit in quotient, bring down next dividend bit Restoring division Do the subtract, and if remainder goes < 0, add divisor back Signed division Divide using absolute values Adjust sign of quotient and remainder as required 3.4 Div vision Chapter 3 Arithmetic for Computers 19

20 Division Hardware Initially divisor in left half Initially dividend Chapter 3 Arithmetic for Computers 20

21 Optimized Divider One cycle per partial-remainder subtraction Looks a lot like a multiplier! Same hardware can be used for both Chapter 3 Arithmetic for Computers 21

22 Faster Division Can t use parallel hardware as in multiplier Subtraction is conditional on sign of remainder Faster dividers (e.g. SRT devision) generate multiple quotient bits per step Still require multiple steps Chapter 3 Arithmetic for Computers 22

23 ARM Division The classic ARM instruction set does not include divide instruction ARMv7R and ARMv7M include Signed integer divide - SDIV Unsigned integer divide id - UDIV Chapter 3 Arithmetic for Computers 23

24 Floating Point Representation for non-integral numbers Including very small and very large numbers 3.5 Flo oating Po oint Like scientific notation normalized not normalized In binary ±1.xxxxxxx 2 2 yyyy Types float and double in C Chapter 3 Arithmetic for Computers 24

25 Floating Point Standard Defined by IEEE Std Developed in response to divergence of representations Portability issues for scientific code Now almost universally adopted Two representations Single precision (32-bit) Double precision i (64-bit) Chapter 3 Arithmetic for Computers 25

26 IEEE Floating-Point Format single: 8 bits double: 11 bits S Exponent single: 23 bits double: 52 bits Fraction x = ( 1) S (1+ Fraction) 2 (Exponent Bias) S: sign bit (0 non-negative, 1 negative) Normalize significand: 1.0 significand < 2.0 Always has a leading pre-binary-point 1 bit, so no need to represent it explicitly (hidden bit) Significand is Fraction with the 1. restored Exponent: excess representation: actual exponent + Bias Ensures exponent is unsigned Single: Bias = 127; Double: Bias = 1203 Chapter 3 Arithmetic for Computers 26

27 IEEE 754 FP Standard Encoding Most (all?) computers these days conform to the IEEE 754 floating point standard (-1) sign x (1+F) x 2 E-bias Formats for both single and double precision F is stored in normalized form where the msb in the fraction is 1 (so there is no need to store it!) called the hidden bit To simplify sorting FP numbers, E comes before F in the word and E is represented in excess (biased) notation Single Precision Double Precision Object Represented E (8) F (23) E (11) F (52) true zero (0) 0 nonzero 0 nonzero ± denormalized number ± anything ± anything ± floating point number ± ± ± infinity 255 nonzero 2047 nonzero not a number (NaN) Chapter 3 Arithmetic for Computers 27

28 Single-Precision Range Exponents and reserved Smallest value Exponent: actual exponent = = 126 Fraction: significand = 1.0 ± ± Largest value exponent: actual exponent = = +127 Fraction: significand 2.0 ± ± Chapter 3 Arithmetic for Computers 28

29 Double-Precision Range Exponents and reserved Smallest value Exponent: actual exponent = = 1022 Fraction: significand = 1.0 ± ± Largest value Exponent: actual exponent = = Fraction: significand 2.0 ± ± Chapter 3 Arithmetic for Computers 29

30 Floating-Point Precision Relative precision all fraction bits are significant Single: approx 2 23 Equivalent to 23 log decimal digits of precision Double: approx 2 52 Equivalent to 52 log decimal digits of precision Chapter 3 Arithmetic for Computers 30

31 Floating-Point Example Represent = ( 1) S = 1 Fraction = Exponent = 1+Bi Bias Single: = 126 = Double: = 1022 = Single: Double: Chapter 3 Arithmetic for Computers 31

32 Floating-Point Example What number is represented by the single- precision i float S = 1 Fraction = Exponent = = 129 x=( ( 1) 1 ( ) 2 = ( 1) = 5.0 ( ) Chapter 3 Arithmetic for Computers 32

33 Denormal Numbers Exponent = hidden bit is 0 x = ( 1) S (0 + Fraction) 2 Bias Smaller than normal numbers allow for gradual underflow, with diminishing precision Denormal with fraction = x S = ( 1) (0 + 0) 2 Bias Two representations of f00! 0.0! = ±0.00 Chapter 3 Arithmetic for Computers 33

34 Infinities and NaNs Exponent = , Fraction = ±Infinity Can be used in subsequent calculations, avoiding need for overflow check Exponent = , 1 Fraction Not-a-Number (NaN) Indicates illegal or undefined result e.g., 0.0 / 0.0 Can be used in subsequent calculations Chapter 3 Arithmetic for Computers 34

35 Floating-Point Addition Consider a 4-digit decimal example Align decimal points Shift number with smaller exponent Add significands ifi = Normalize result & check for over/underflow Round and renormalize if necessary Chapter 3 Arithmetic for Computers 35

36 Floating-Point Addition Now consider a 4-digit binary example ( ) 1. Align binary points Shift number with smaller exponent Add significands ifi = Normalize result & check for over/underflow , with no over/underflow 4. Round and renormalize if necessary (no change) = Chapter 3 Arithmetic for Computers 36

37 FP Adder Hardware Much more complex than integer adder Doing it in one clock cycle would take too long Much longer than integer operations Slower clock would penalize all instructions FP adder usually takes several cycles Can be pipelined Chapter 3 Arithmetic for Computers 37

38 FP Adder Hardware Step 1 Step 2 Step 3 Step 4 Chapter 3 Arithmetic for Computers 38

39 Floating-Point Multiplication Consider a 4-digit decimal example Add exponents For biased exponents, subtract bias from sum New exponent = = 5 2. Multiply significands = Normalize result & check for over/underflow Round and renormalize if necessary Determine sign of result from signs of operands Chapter 3 Arithmetic for Computers 39

40 Floating-Point Multiplication Now consider a 4-digit binary example ( ) 1. Add exponents Unbiased: = 3 Biased: ( ) + ( ) = = Multiply significands = Normalize result & check for over/underflow (no change) with no over/underflow 4. Round and renormalize if necessary (no change) 5. Determine sign: +ve ve ve = Chapter 3 Arithmetic for Computers 40

41 FP Arithmetic Hardware FP multiplier is of similar complexity to FP adder But uses a multiplier for significands instead of an adder FP arithmetic hardware usually does Addition, subtraction, multiplication, division, reciprocal, square-root FP integer conversion Operations usually takes several cycles Can be pipelined Chapter 3 Arithmetic for Computers 41

42 FP Instructions in ARM FP hardware is coprocessor 1 Adjunct processor that extends the ISA Separate FP registers 32 single-precision: s0, s1, s31 Paired for double-precision: s0/s1, s2/s3, to give 16 double precision registers : d0,d1..d15 FP instructions operate only on FP registers Programs generally don t do integer ops on FP data, or vice versa More registers with minimal code-size impact FP load and store instructions FLDS,FSTS,FLDD,FSTD e.g., FLDS s1, [r1,#100] ; s1 = mem [r1+400] Chapter 3 Arithmetic for Computers 42

43 FP Instructions in ARM Single-precision arithmetic FADDS,FSUBS,FMULS,FDIVSFSUBS FMULS FDIVS e.g., FADDS s2,s4,s6 ; s2 = s4 + s6 Double-precision arithmetic FADDD,FSUBD,FMULD,FDIVD e.g., FSUBD d2,d4,d6 ; d2 = d4 d6 Single- and double-precision comparison FCMPS, FCMPD e.g. FCMPS s2,s4 ; if (s2 s4) Branch on FP condition flag FMSTAT ; cond.flags = FP cond. flags Copy FP condition flags to integer condition flag Chapter 3 Arithmetic for Computers 43

44 Summary of ARM FP instructions discussed thus far Chapter 3 Arithmetic for Computers 44

45 FP Example: F to C C code: float f2c (float fahr) { return ((5.0/9.0)*(fahr )); } fahr in s12, result in s0, literals in global memory space Compiled ARM code: f2c: FLDS s16, [r12, const5] ;s16 = 5.0 FLDS s18, [r12, const9] ;s18 = 9.0 FDIVS s16,s16,s18 ; s16 = 5.0/9.0 FLDS s18, [r12,const32] ; s18 = 32.0 FSUBS s18,s12,s18 s12 ; s18 = fahr 32 FMULS s0,s16,s18 ; s0 = (5/9)* (fahr 32) MOV pc,lr ; return Chapter 3 Arithmetic for Computers 45

46 FP Example: Array Multiplication X = X + Y Z All matrices, 64-bit double-precision i elements C code: void mm (double x[][], double y[][], double z[][]) { int i, j, k; for (i = 0; i! = 32; i = i + 1) for (j = 0; j! = 32; j = j + 1) for (k = 0; k! = 32; k = k + 1) x[i][j] = x[i][j] + y[i][k] * z[k][j]; } Chapter 3 Arithmetic for Computers 46

47 FP Example: Array Multiplication ARM code: Addresses of variable x, y, z in r0, r1, r2, and i,j, j k in r3, r4, r5. The address of x[ i ][ j ] is r6 and address of y[ i ][ j ] or z[ i ][ j ] is r12. Mm: SUB sp,sp,#12 ; make room on stack for 3 regs STR r4,[sp,#8] ; save r4 on stack STR r5,[sp,#4] ; save r5 on stack STR r6,[sp,#0] ; save r6 on stack MOV i, 0 ; i = 0 initialize 1 st for loop L1: MOV j, 0 ; j = 0 restart 2 nd for loop L2: MOV k,0 ; k = 0 restart 3 rd for loop ADD xijaddr,j,i, LSL #5 ; xijaddr = i*size(row) + j ADD xijaddr,x,xijaddr,lsl #3 ; xijaddr = byte address of x[i][j] Chapter 3 Arithmetic for Computers 47

48 FP Example: Array Multiplication FLDD s4, [xijaddr,#0] ; s4 = 8 bytes of x[i][j] L3: ADD tempaddr, j,k,lsl #5 ; tempaddr = k *size(row) + j ADD tempaddr,z,tempaddr,lsl #3 ; tempaddr= byte ;address of z[k][j] FLDD s16,[tempaddr,#0] ; s16 = 8 bytes of z[k][j] ADD tempaddr, k,i,lsl #5 ; tempaddr = i *size(row) + k ADD tempaddr,y,tempaddr,lsl #3 ; tempaddr= byte ;address of y[i][k] FLDD s18,[tempaddr,#0] ; s18 = 8 bytes of y[i][k] FMULD s16,s18,s16 s18 ; s16 = y[i][k] * z[k][j] FADDD s4,s4,s16 ; s4 =x[i][j] + ; y[i][k]*z[k][j] Chapter 3 Arithmetic for Computers 48

49 FP Example: Array Multiplication ADD k,k,#1 ; k = k+1 CMP k, #32 BLT L3 ; if (k<32) go to L3 FSTD s4, [xijaddr,#0] ; x[i][j] = s4 ADD j,j, #1 ; j = j+1 CMP j #32 BLT ls ; if ( j<32) go to L2 ADD i,i, #1 ; i = i + 1 CMP i, #32 BLT L1 ; if ( i<32) go to L1 Chapter 3 Arithmetic for Computers 49

50 Accurate Arithmetic IEEE Std 754 specifies additional rounding control Extra bits of precision (guard, round, sticky) Choice of rounding modes Allows programmer to fine-tune numerical behavior of a computation Not all FP units implement all options Most programming g languages g and FP libraries just use defaults Trade-off between hardware complexity, performance, and market requirements Chapter 3 Arithmetic for Computers 50

51 Interpretation of Data The BIG Picture Bits have no inherent meaning Interpretation depends on the instructions applied Computer representations of numbers Finite range and precision Need to account for this in programs Chapter 3 Arithmetic for Computers 51

52 Associativity Parallel programs may interleave operations in unexpected orders Assumptions of associativity may fail (x+y)+z x+(y+z) x -1.50E E+38 y 1.50E E+00 z E E E+00 Need to validate parallel l programs under varying degrees of parallelism 3.6 Pa arallelism and Com mputer Arithmetic c: Associa ativity Chapter 3 Arithmetic for Computers 52

53 Right Shift and Division Left shift by i places multiplies an integer by 2 i Right shift divides by 2 i? Only for unsigned integers For signed integers Arithmetic right shift: replicate the sign bit eg e.g., 5/ >> 2 = = 2 Rounds toward c.f >>> 2 = = Fa llacies an nd Pitfalls Chapter 3 Arithmetic for Computers 53

54 Who Cares About FP Accuracy? Important for scientific code But for everyday consumer use? My bank balance is out by ! The Intel Pentium FDIV bug The market expects accuracy See Colwell, The Pentium Chronicles Chapter 3 Arithmetic for Computers 54

55 Concluding Remarks ISAs support arithmetic Signed and unsigned integers Floating-point approximation to reals Bounded range and precision Operations can overflow and underflow ARM core instructions dominate integer SPEC2006 execution and integer and arithmetic core dominate SPEC2006 floating point execution. 3.9 Co oncluding Remark ks Chapter 3 Arithmetic for Computers 55

Chapter 3 Arithmetic for Computers

Chapter 3 Arithmetic for Computers Chapter 3 Arithmetic for Computers 1 Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

Chapter 3. Arithmetic Text: P&H rev

Chapter 3. Arithmetic Text: P&H rev Chapter 3 Arithmetic Text: P&H rev3.29.16 Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

Thomas Polzer Institut für Technische Informatik

Thomas Polzer Institut für Technische Informatik Thomas Polzer tpolzer@ecs.tuwien.ac.at Institut für Technische Informatik Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers VO

More information

Chapter 3. Arithmetic for Computers

Chapter 3. Arithmetic for Computers Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

Floating Point Arithmetic

Floating Point Arithmetic Floating Point Arithmetic Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3050: Theory on Computer Architectures, Spring 2017, Jinkyu Jeong (jinkyu@skku.edu)

More information

TDT4255 Computer Design. Lecture 4. Magnus Jahre

TDT4255 Computer Design. Lecture 4. Magnus Jahre 1 TDT4255 Computer Design Lecture 4 Magnus Jahre 2 Chapter 3 Computer Arithmetic ti Acknowledgement: Slides are adapted from Morgan Kaufmann companion material 3 Arithmetic for Computers Operations on

More information

Chapter 3. Arithmetic for Computers

Chapter 3. Arithmetic for Computers Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

Chapter 3. Arithmetic for Computers

Chapter 3. Arithmetic for Computers Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

Computer Architecture and IC Design Lab. Chapter 3 Part 2 Arithmetic for Computers Floating Point

Computer Architecture and IC Design Lab. Chapter 3 Part 2 Arithmetic for Computers Floating Point Chapter 3 Part 2 Arithmetic for Computers Floating Point Floating Point Representation for non integral numbers Including very small and very large numbers 4,600,000,000 or 4.6 x 10 9 0.0000000000000000000000000166

More information

Arithmetic for Computers. Hwansoo Han

Arithmetic for Computers. Hwansoo Han Arithmetic for Computers Hwansoo Han Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

Floating Point Arithmetic. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Floating Point Arithmetic. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Floating Point Arithmetic Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Floating Point (1) Representation for non-integral numbers Including very

More information

COMPUTER ORGANIZATION AND DESIGN

COMPUTER ORGANIZATION AND DESIGN COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication

More information

COMPUTER ORGANIZATION AND. Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

COMPUTER ORGANIZATION AND. Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers ARM D COMPUTER ORGANIZATION AND Edition The Hardware/Software Interface Chapter 3 Arithmetic for Computers Modified and extended by R.J. Leduc - 2016 In this chapter, we will investigate: How integer arithmetic

More information

CSCI 402: Computer Architectures. Arithmetic for Computers (4) Fengguang Song Department of Computer & Information Science IUPUI.

CSCI 402: Computer Architectures. Arithmetic for Computers (4) Fengguang Song Department of Computer & Information Science IUPUI. CSCI 402: Computer Architectures Arithmetic for Computers (4) Fengguang Song Department of Computer & Information Science IUPUI Homework 4 Assigned on Feb 22, Thursday Due Time: 11:59pm, March 5 on Monday

More information

Integer Arithmetic. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Integer Arithmetic. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University Integer Arithmetic Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3050: Theory on Computer Architectures, Spring 2017, Jinkyu Jeong (jinkyu@skku.edu)

More information

Chapter 3 Arithmetic for Computers (Part 2)

Chapter 3 Arithmetic for Computers (Part 2) Department of Electr rical Eng ineering, Chapter 3 Arithmetic for Computers (Part 2) 王振傑 (Chen-Chieh Wang) ccwang@mail.ee.ncku.edu.tw ncku edu Depar rtment of Electr rical Eng ineering, Feng-Chia Unive

More information

Written Homework 3. Floating-Point Example (1/2)

Written Homework 3. Floating-Point Example (1/2) Written Homework 3 Assigned on Tuesday, Feb 19 Due Time: 11:59pm, Feb 26 on Tuesday Problems: 3.22, 3.23, 3.24, 3.41, 3.43 Note: You have 1 week to work on homework 3. 3 Floating-Point Example (1/2) Q:

More information

September, 2003 Saeid Nooshabadi

September, 2003 Saeid Nooshabadi COMP3211 lec21-fp-iii.1 COMP 3221 Microprocessors and Embedded Systems Lectures 21 : Floating Point Number Representation III http://www.cse.unsw.edu.au/~cs3221 September, 2003 Saeid@unsw.edu.au Overview

More information

Review: MIPS Organization

Review: MIPS Organization 1 MIPS Arithmetic Review: MIPS Organization Processor Memory src1 addr 5 src2 addr 5 dst addr 5 write data Register File registers ($zero - $ra) bits src1 data src2 data read/write addr 1 1100 2 30 words

More information

Computer Architecture. Chapter 3: Arithmetic for Computers

Computer Architecture. Chapter 3: Arithmetic for Computers 182.092 Computer Architecture Chapter 3: Arithmetic for Computers Adapted from Computer Organization and Design, 4 th Edition, Patterson & Hennessy, 2008, Morgan Kaufmann Publishers and Mary Jane Irwin

More information

Module 2: Computer Arithmetic

Module 2: Computer Arithmetic Module 2: Computer Arithmetic 1 B O O K : C O M P U T E R O R G A N I Z A T I O N A N D D E S I G N, 3 E D, D A V I D L. P A T T E R S O N A N D J O H N L. H A N N E S S Y, M O R G A N K A U F M A N N

More information

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Computer Organization and Structure. Bing-Yu Chen National Taiwan University Computer Organization and Structure Bing-Yu Chen National Taiwan University Arithmetic for Computers Addition and Subtraction Gate Logic and K-Map Method Constructing a Basic ALU Arithmetic Logic Unit

More information

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Boolean Algebra Boolean algebra is the basic math used in digital circuits and computers.

More information

CSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI.

CSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI. CSCI 402: Computer Architectures Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI 3.5 Today s Contents Floating point numbers: 2.5, 10.1, 100.2, etc.. How

More information

Chapter 3. Floating Point. Floating Point Standard. Morgan Kaufmann Publishers 13 November, Chapter 3 Arithmetic for Computers 1

Chapter 3. Floating Point. Floating Point Standard. Morgan Kaufmann Publishers 13 November, Chapter 3 Arithmetic for Computers 1 COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface RISC-V Edition Chapter 3 Arithmetic for Computers Floating Point Numbers Floating Point Representation for non-integral numbers Including

More information

Boolean Algebra. Chapter 3. Boolean Algebra. Chapter 3 Arithmetic for Computers 1. Fundamental Boolean Operations. Arithmetic for Computers

Boolean Algebra. Chapter 3. Boolean Algebra. Chapter 3 Arithmetic for Computers 1. Fundamental Boolean Operations. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic

More information

Divide: Paper & Pencil

Divide: Paper & Pencil Divide: Paper & Pencil 1001 Quotient Divisor 1000 1001010 Dividend -1000 10 101 1010 1000 10 Remainder See how big a number can be subtracted, creating quotient bit on each step Binary => 1 * divisor or

More information

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering Arithmetic for Computers James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy Arithmetic for

More information

ECE232: Hardware Organization and Design

ECE232: Hardware Organization and Design ECE232: Hardware Organization and Design Lecture 11: Floating Point & Floating Point Addition Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Last time: Single Precision Format

More information

September, Saeid Nooshabadi. Overview IEEE 754 Standard COMP Microprocessors and Embedded Systems

September, Saeid Nooshabadi. Overview IEEE 754 Standard COMP Microprocessors and Embedded Systems COMP3221 lec20-fp-ii.1 COMP 3221 Microprocessors and Embedded Systems Lectures 20 : Floating Point Number Representation II http://www.cse.unsw.edu.au/~cs3221 September, 2003 Saeid@unsw.edu.au Overview

More information

ECE 154A Introduction to. Fall 2012

ECE 154A Introduction to. Fall 2012 ECE 154A Introduction to Computer Architecture Fall 2012 Dmitri Strukov Lecture 10 Floating point review Pipelined design IEEE Floating Point Format single: 8 bits double: 11 bits single: 23 bits double:

More information

Recap from Last Time. CSE 2021: Computer Organization. It s All about Numbers! 5/12/2011. Text Pictures Video clips Audio

Recap from Last Time. CSE 2021: Computer Organization. It s All about Numbers! 5/12/2011. Text Pictures Video clips Audio CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-2(a) Data Translation Binary patterns, signed and unsigned integers Today s topic Data Translation Code Translation

More information

COMP2611: Computer Organization. Data Representation

COMP2611: Computer Organization. Data Representation COMP2611: Computer Organization Comp2611 Fall 2015 2 1. Binary numbers and 2 s Complement Numbers 3 Bits: are the basis for binary number representation in digital computers What you will learn here: How

More information

Floating Point COE 308. Computer Architecture Prof. Muhamed Mudawar. Computer Engineering Department King Fahd University of Petroleum and Minerals

Floating Point COE 308. Computer Architecture Prof. Muhamed Mudawar. Computer Engineering Department King Fahd University of Petroleum and Minerals Floating Point COE 38 Computer Architecture Prof. Muhamed Mudawar Computer Engineering Department King Fahd University of Petroleum and Minerals Presentation Outline Floating-Point Numbers IEEE 754 Floating-Point

More information

Arithmetic for Computers. Integer Addition. Chapter 3

Arithmetic for Computers. Integer Addition. Chapter 3 COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication

More information

Instruction Set extensions to X86. Floating Point SIMD instructions

Instruction Set extensions to X86. Floating Point SIMD instructions Instruction Set extensions to X86 Some extensions to x86 instruction set intended to accelerate 3D graphics AMD 3D-Now! Instructions simply accelerate floating point arithmetic. Accelerate object transformations

More information

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University Computer Architecture Chapter 3 Fall 2005 Department of Computer Science Kent State University Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point

More information

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3 Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Instructor: Nicole Hynes nicole.hynes@rutgers.edu 1 Fixed Point Numbers Fixed point number: integer part

More information

MIPS Integer ALU Requirements

MIPS Integer ALU Requirements MIPS Integer ALU Requirements Add, AddU, Sub, SubU, AddI, AddIU: 2 s complement adder/sub with overflow detection. And, Or, Andi, Ori, Xor, Xori, Nor: Logical AND, logical OR, XOR, nor. SLTI, SLTIU (set

More information

Signed Multiplication Multiply the positives Negate result if signs of operand are different

Signed Multiplication Multiply the positives Negate result if signs of operand are different Another Improvement Save on space: Put multiplier in product saves on speed: only single shift needed Figure: Improved hardware for multiplication Signed Multiplication Multiply the positives Negate result

More information

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication

More information

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication

More information

Integer Subtraction. Chapter 3. Overflow conditions. Arithmetic for Computers. Signed Addition. Integer Addition. Arithmetic for Computers

Integer Subtraction. Chapter 3. Overflow conditions. Arithmetic for Computers. Signed Addition. Integer Addition. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Integer Subtraction Chapter 3 Arithmetic for Computers Add negation of second operand Example: 7 6 = 7 + ( 6) +7: 0000 0000

More information

Lecture 13: (Integer Multiplication and Division) FLOATING POINT NUMBERS

Lecture 13: (Integer Multiplication and Division) FLOATING POINT NUMBERS Lecture 13: (Integer Multiplication and Division) FLOATING POINT NUMBERS Lecture 13 Floating Point I (1) Fall 2005 Integer Multiplication (1/3) Paper and pencil example (unsigned): Multiplicand 1000 8

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 15: Midterm 1 Review Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Basics Midterm to cover Book Sections (inclusive) 1.1 1.5

More information

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring EE 260: Introduction to Digital Design Arithmetic II Yao Zheng Department of Electrical Engineering University of Hawaiʻi at Mānoa Overview n Integer multiplication n Booth s algorithm n Integer division

More information

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication

More information

CO212 Lecture 10: Arithmetic & Logical Unit

CO212 Lecture 10: Arithmetic & Logical Unit CO212 Lecture 10: Arithmetic & Logical Unit Shobhanjana Kalita, Dept. of CSE, Tezpur University Slides courtesy: Computer Architecture and Organization, 9 th Ed, W. Stallings Integer Representation For

More information

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666 UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Digital Computer Arithmetic ECE 666 Part 4-A Floating-Point Arithmetic Israel Koren ECE666/Koren Part.4a.1 Preliminaries - Representation

More information

Floating Point Arithmetic

Floating Point Arithmetic Floating Point Arithmetic CS 365 Floating-Point What can be represented in N bits? Unsigned 0 to 2 N 2s Complement -2 N-1 to 2 N-1-1 But, what about? very large numbers? 9,349,398,989,787,762,244,859,087,678

More information

Chapter 3 Arithmetic for Computers

Chapter 3 Arithmetic for Computers Chapter 3 Arithmetic for Computers 1 Outline Signed and unsigned numbers (Sec. 3.2) Addition and subtraction (Sec. 3.3) Multiplication (Sec. 3.4) Division (Sec. 3.5) Floating point (Sec. 3.6) 2 Representation

More information

3.5 Floating Point: Overview

3.5 Floating Point: Overview 3.5 Floating Point: Overview Floating point (FP) numbers Scientific notation Decimal scientific notation Binary scientific notation IEEE 754 FP Standard Floating point representation inside a computer

More information

C NUMERIC FORMATS. Overview. IEEE Single-Precision Floating-point Data Format. Figure C-0. Table C-0. Listing C-0.

C NUMERIC FORMATS. Overview. IEEE Single-Precision Floating-point Data Format. Figure C-0. Table C-0. Listing C-0. C NUMERIC FORMATS Figure C-. Table C-. Listing C-. Overview The DSP supports the 32-bit single-precision floating-point data format defined in the IEEE Standard 754/854. In addition, the DSP supports an

More information

Chapter Three. Arithmetic

Chapter Three. Arithmetic Chapter Three 1 Arithmetic Where we've been: Performance (seconds, cycles, instructions) Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: Implementing

More information

Arithmetic. Chapter 3 Computer Organization and Design

Arithmetic. Chapter 3 Computer Organization and Design Arithmetic Chapter 3 Computer Organization and Design Addition Addition is similar to decimals 0000 0111 + 0000 0101 = 0000 1100 Subtraction (negate) 0000 0111 + 1111 1011 = 0000 0010 Over(under)flow For

More information

Chapter 3: Arithmetic for Computers

Chapter 3: Arithmetic for Computers Chapter 3: Arithmetic for Computers Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point Computer Architecture CS 35101-002 2 The Binary Numbering

More information

5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner. Topic 3: Arithmetic

5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner. Topic 3: Arithmetic 5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner Topic 3: Arithmetic These slides are mostly taken verbatim, or with minor changes, from those

More information

Number Systems and Computer Arithmetic

Number Systems and Computer Arithmetic Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction R-format I-format... integer data number text

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 10: Multiplication & Floating Point Representation Adapted from Computer Organization and Design, Patterson & Hennessy, UCB MIPS Division Two 32-bit registers

More information

Computer Architecture Set Four. Arithmetic

Computer Architecture Set Four. Arithmetic Computer Architecture Set Four Arithmetic Arithmetic Where we ve been: Performance (seconds, cycles, instructions) Abstractions: Instruction Set Architecture Assembly Language and Machine Language What

More information

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right. Floating-point Arithmetic Reading: pp. 312-328 Floating-Point Representation Non-scientific floating point numbers: A non-integer can be represented as: 2 4 2 3 2 2 2 1 2 0.2-1 2-2 2-3 2-4 where you sum

More information

Floating Point Numbers

Floating Point Numbers Floating Point Numbers Summer 8 Fractional numbers Fractional numbers fixed point Floating point numbers the IEEE 7 floating point standard Floating point operations Rounding modes CMPE Summer 8 Slides

More information

Numeric Encodings Prof. James L. Frankel Harvard University

Numeric Encodings Prof. James L. Frankel Harvard University Numeric Encodings Prof. James L. Frankel Harvard University Version of 10:19 PM 12-Sep-2017 Copyright 2017, 2016 James L. Frankel. All rights reserved. Representation of Positive & Negative Integral and

More information

Floating Point (with contributions from Dr. Bin Ren, William & Mary Computer Science)

Floating Point (with contributions from Dr. Bin Ren, William & Mary Computer Science) Floating Point (with contributions from Dr. Bin Ren, William & Mary Computer Science) Floating Point Background: Fractional binary numbers IEEE floating point standard: Definition Example and properties

More information

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures Homework 3 Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) 1 CSCI 402: Computer Architectures Arithmetic for Computers (2) Fengguang Song Department

More information

Integer Multiplication. Back to Arithmetic. Integer Multiplication. Example (Fig 4.25)

Integer Multiplication. Back to Arithmetic. Integer Multiplication. Example (Fig 4.25) Back to Arithmetic Before, we did Representation of integers Addition/Subtraction Logical ops Forecast Integer Multiplication Integer Division Floating-point Numbers Floating-point Addition/Multiplication

More information

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction 1 Floating Point The World is Not Just Integers Programming languages support numbers with fraction Called floating-point numbers Examples: 3.14159265 (π) 2.71828 (e) 0.000000001 or 1.0 10 9 (seconds in

More information

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754 Floating Point Puzzles Topics Lecture 3B Floating Point IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties For each of the following C expressions, either: Argue that

More information

Floating-Point Arithmetic

Floating-Point Arithmetic ENEE446---Lectures-4/10-15/08 A. Yavuz Oruç Professor, UMD, College Park Copyright 2007 A. Yavuz Oruç. All rights reserved. Floating-Point Arithmetic Integer or fixed-point arithmetic provides a complete

More information

September, Saeid Nooshabadi. Review: Floating Point Representation COMP Single Precision and Double Precision

September, Saeid Nooshabadi. Review: Floating Point Representation COMP Single Precision and Double Precision Review: Floating Point Representation COMP3211 lec22-fraction1 COMP 3221 Microprocessors and Embedded Systems Lectures 22 : Fractions http://wwwcseunsweduau/~cs3221 September, 2003 Saeid@unsweduau Single

More information

Chapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation

Chapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation Chapter 2 Float Point Arithmetic Topics IEEE Floating Point Standard Fractional Binary Numbers Rounding Floating Point Operations Mathematical properties Real Numbers in Decimal Notation Representation

More information

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Arithmetic (a) The four possible cases Carry (b) Truth table x y

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Arithmetic (a) The four possible cases Carry (b) Truth table x y Arithmetic A basic operation in all digital computers is the addition and subtraction of two numbers They are implemented, along with the basic logic functions such as AND,OR, NOT,EX- OR in the ALU subsystem

More information

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666 UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Digital Computer Arithmetic ECE 666 Part 4-C Floating-Point Arithmetic - III Israel Koren ECE666/Koren Part.4c.1 Floating-Point Adders

More information

Organisasi Sistem Komputer

Organisasi Sistem Komputer LOGO Organisasi Sistem Komputer OSK 8 Aritmatika Komputer 1 1 PT. Elektronika FT UNY Does the calculations Arithmetic & Logic Unit Everything else in the computer is there to service this unit Handles

More information

CS 101: Computer Programming and Utilization

CS 101: Computer Programming and Utilization CS 101: Computer Programming and Utilization Jul-Nov 2017 Umesh Bellur (cs101@cse.iitb.ac.in) Lecture 3: Number Representa.ons Representing Numbers Digital Circuits can store and manipulate 0 s and 1 s.

More information

CPE300: Digital System Architecture and Design

CPE300: Digital System Architecture and Design CPE300: Digital System Architecture and Design Fall 2011 MW 17:30-18:45 CBC C316 Arithmetic Unit 10122011 http://www.egr.unlv.edu/~b1morris/cpe300/ 2 Outline Recap Fixed Point Arithmetic Addition/Subtraction

More information

Foundations of Computer Systems

Foundations of Computer Systems 18-600 Foundations of Computer Systems Lecture 4: Floating Point Required Reading Assignment: Chapter 2 of CS:APP (3 rd edition) by Randy Bryant & Dave O Hallaron Assignments for This Week: Lab 1 18-600

More information

Chapter 3 Arithmetic for Computers. ELEC 5200/ From P-H slides

Chapter 3 Arithmetic for Computers. ELEC 5200/ From P-H slides Chapter 3 Arithmetic for Computers 1 Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

M1 Computers and Data

M1 Computers and Data M1 Computers and Data Module Outline Architecture vs. Organization. Computer system and its submodules. Concept of frequency. Processor performance equation. Representation of information characters, signed

More information

Floating Point Numbers. Lecture 9 CAP

Floating Point Numbers. Lecture 9 CAP Floating Point Numbers Lecture 9 CAP 3103 06-16-2014 Review of Numbers Computers are made to deal with numbers What can we represent in N bits? 2 N things, and no more! They could be Unsigned integers:

More information

xx.yyyy Lecture #11 Floating Point II Summary (single precision): Precision and Accuracy Fractional Powers of 2 Representation of Fractions

xx.yyyy Lecture #11 Floating Point II Summary (single precision): Precision and Accuracy Fractional Powers of 2 Representation of Fractions CS61C L11 Floating Point II (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #11 Floating Point II 2007-7-12 Scott Beamer, Instructor Sony & Nintendo make E3 News www.nytimes.com Review

More information

Floating point. Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties. Next time. !

Floating point. Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties. Next time. ! Floating point Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties Next time! The machine model Chris Riesbeck, Fall 2011 Checkpoint IEEE Floating point Floating

More information

Computer Arithmetic Ch 8

Computer Arithmetic Ch 8 Computer Arithmetic Ch 8 ALU Integer Representation Integer Arithmetic Floating-Point Representation Floating-Point Arithmetic 1 Arithmetic Logical Unit (ALU) (2) (aritmeettis-looginen yksikkö) Does all

More information

Computer Arithmetic Ch 8

Computer Arithmetic Ch 8 Computer Arithmetic Ch 8 ALU Integer Representation Integer Arithmetic Floating-Point Representation Floating-Point Arithmetic 1 Arithmetic Logical Unit (ALU) (2) Does all work in CPU (aritmeettis-looginen

More information

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating Point. CSE 351 Autumn Instructor: Justin Hsia Floating Point CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun http://xkcd.com/899/

More information

Floating Point Arithmetic

Floating Point Arithmetic Floating Point Arithmetic ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals [Adapted from

More information

IEEE Standard 754 for Binary Floating-Point Arithmetic.

IEEE Standard 754 for Binary Floating-Point Arithmetic. CS61C L11 Floating Point II (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #11 Floating Point II 2005-10-05 There is one handout today at the front and back of the room! Lecturer

More information

By, Ajinkya Karande Adarsh Yoga

By, Ajinkya Karande Adarsh Yoga By, Ajinkya Karande Adarsh Yoga Introduction Early computer designers believed saving computer time and memory were more important than programmer time. Bug in the divide algorithm used in Intel chips.

More information

Floating Point January 24, 2008

Floating Point January 24, 2008 15-213 The course that gives CMU its Zip! Floating Point January 24, 2008 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties class04.ppt 15-213, S 08 Floating

More information

Chapter 2 Data Representations

Chapter 2 Data Representations Computer Engineering Chapter 2 Data Representations Hiroaki Kobayashi 4/21/2008 4/21/2008 1 Agenda in Chapter 2 Translation between binary numbers and decimal numbers Data Representations for Integers

More information

IEEE Standard for Floating-Point Arithmetic: 754

IEEE Standard for Floating-Point Arithmetic: 754 IEEE Standard for Floating-Point Arithmetic: 754 G.E. Antoniou G.E. Antoniou () IEEE Standard for Floating-Point Arithmetic: 754 1 / 34 Floating Point Standard: IEEE 754 1985/2008 Established in 1985 (2008)

More information

UNIT-III COMPUTER ARTHIMETIC

UNIT-III COMPUTER ARTHIMETIC UNIT-III COMPUTER ARTHIMETIC INTRODUCTION Arithmetic Instructions in digital computers manipulate data to produce results necessary for the of activity solution of computational problems. These instructions

More information

Systems I. Floating Point. Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties

Systems I. Floating Point. Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Systems I Floating Point Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties IEEE Floating Point IEEE Standard 754 Established in 1985 as uniform standard for

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #11 Floating Point II Scott Beamer, Instructor Sony & Nintendo make E3 News 2007-7-12 CS61C L11 Floating Point II (1) www.nytimes.com Review

More information

CS61C Floating Point Operations & Multiply/Divide. Lecture 9. February 17, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson)

CS61C Floating Point Operations & Multiply/Divide. Lecture 9. February 17, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson) CS61C Floating Point Operations & Multiply/Divide Lecture 9 February 17, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson) www-inst.eecs.berkeley.edu/~cs61c/schedule.html cs 61C L9 FP.1 Review 1/2

More information

Divide: Paper & Pencil CS152. Computer Architecture and Engineering Lecture 7. Divide, Floating Point, Pentium Bug. DIVIDE HARDWARE Version 1

Divide: Paper & Pencil CS152. Computer Architecture and Engineering Lecture 7. Divide, Floating Point, Pentium Bug. DIVIDE HARDWARE Version 1 Divide: Paper & Pencil Computer Architecture and Engineering Lecture 7 Divide, Floating Point, Pentium Bug 1001 Quotient 1000 1001010 Dividend 1000 10 101 1010 1000 10 (or Modulo result) See how big a

More information

Review 1/2 Big Idea: Instructions determine meaning of data; nothing inherent inside the data Characters: ASCII takes one byte

Review 1/2 Big Idea: Instructions determine meaning of data; nothing inherent inside the data Characters: ASCII takes one byte CS61C Floating Point Operations & Multiply/Divide Lecture 9 February 17, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson) www-inst.eecs.berkeley.edu/~cs61c/schedule.html Review 1/2 Big Idea: Instructions

More information

The Sign consists of a single bit. If this bit is '1', then the number is negative. If this bit is '0', then the number is positive.

The Sign consists of a single bit. If this bit is '1', then the number is negative. If this bit is '0', then the number is positive. IEEE 754 Standard - Overview Frozen Content Modified by on 13-Sep-2017 Before discussing the actual WB_FPU - Wishbone Floating Point Unit peripheral in detail, it is worth spending some time to look at

More information

CSCI 402: Computer Architectures

CSCI 402: Computer Architectures CSCI 402: Computer Architectures Arithmetic for Computers (5) Fengguang Song Department of Computer & Information Science IUPUI What happens when the exact result is not any floating point number, too

More information

Chapter 5 : Computer Arithmetic

Chapter 5 : Computer Arithmetic Chapter 5 Computer Arithmetic Integer Representation: (Fixedpoint representation): An eight bit word can be represented the numbers from zero to 255 including = 1 = 1 11111111 = 255 In general if an nbit

More information