New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Machine Structures

by: Mr. Hayley Barton

Machine Structures COMPSCI 61Cl

Mr. Hayley Barton

GPA 3.93


Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Class Notes
25 ?




Popular in Course

Popular in ComputerScienence

This 6 page Class Notes was uploaded by Mr. Hayley Barton on Thursday October 22, 2015. The Class Notes belongs to COMPSCI 61Cl at University of California - Berkeley taught by Staff in Fall. Since its upload, it has received 27 views. For similar materials see /class/226659/compsci-61cl-university-of-california-berkeley in ComputerScienence at University of California - Berkeley.


Reviews for Machine Structures


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/22/15
inst eecs berkeley educs6lc UC BerkeleV CS61C Machine Structures Lecture 16 Floating Point 11 2008 02 29 TA Oddinaire Keaton Mowery WWW cs berkeley educs6lc tk Electron Filmed for the First Time Scientists have filmed an electron in motion for the rst time using a new directlyquot mnlinn A d 39 39 r short pulses of intense laser light called allosecond pulses to gel the job donequot http WW livescience cumstrangeneWsAJEDZZSre emvunrmuvie mm anely Spring Inn 22 uca Review Floating Point lets us makes ef cient use of available bits to count by 14 121 Exponent tells Significand how much 2 2 u Represent numbers containing both integer and fractional parts a Store approximate values for very large and very small 5 IEEE 754 Floating Point Standard is most widely accepted attempt to standardize interpretation of such numbers Every desktop or server computer sold since 1997 follows these conventions Summary single precision 123 x 1 Significand X 2EXP quotEquotquot127 1023 half quad similar 31 30 23 22 o Exponent ignificand 1 bit 8 bits 23 bits Double precision identical except with exponent bias of anely Spring Inn 22 uca Father of the Floating point standard IEEE Standard l 754 for Binary FloatingPoint Arithmetic 1989 ACM Turing Award Winner PrOf Kahan wwwcsberkeleyeduwkahan mieee754status754storyhtml Q anely Spring Inn 22 uca Precision and Accuracy Don t confuse these two terms used to represent a value High precision permits high accuracy but doesn t guarantee it It is possible to have high precision but low accuracy Example float pi 3 14 pi will be represented using all 24 bits of the significant highly precise but is only an approximation not accurate Q Precision is a count of the number bits in a computer word Accuracy is a measure of the difference between the actual value of a number and its computer representation anely Spring Inn 22 uca Representation for i 00 In FP divide by 0 should produce 1 00 not overflow Why a OK to do further computations with w Eg XIO gt Y may be a valid comparison a Ask math majors IEEE 754 represents 1 00 a Most positive exponent reserved for w n Significands all zeroes anely Spring Inn 22 uca Representation for 0 Represent 0 n exponent all zeroes n significand all zeroes a What about sign Both cases valid 0 0 00000000 00000000000000000000000 0 1 00000000 00000000000000000000000 anely Spring Inn 22 uca Special Numbers What have we de ned so far Single Professor Kahan had clever ideas Waste not want not a We ll talk about Exp0255 amp Sig0 later Mmry Smrgm x uca Representation for Not a Number What do I get ifl calculate sqrt 4 0 or 00 a If 0 not an error these shouldn t be either a Called Not a Number NaN u Exponent 255 Significand nonzero Why is this useful a Hope NaNs help with debugging a They contaminate opNaN X NaN Mmry Smrgm x uca Representation for Denorms 12 Problem There s a gap among representable FP numbers around 0 u Smallest representable pos num a 10 2 2126 2126 a Second smallest representable pos num b1000 12 2126 1 00012 2426 Normalization and 1 223 2126 implicit 1 242 2145 is to blame Mmry Smrgm x uca Representation for Denorm 22 Solution n We still haven t used Exponent0 Significand nonzero u Denonnalized number no implied leading 1 implicit exponent 126 u Smallest representable pos num 2145 a Second smallest representable pos num b 2145 wiuuuuuuuiiiLw o Mmry Smrgm x uca Special Numbers Summary Reserve exponents significands nonzero nonzero Mmry Smrgm x uca Rounding When we perform math on real numbers we have to worry about rounding to fit the result in the signi cant field The FP hardware carries two extra bits of precision and then round to get the proper value Rounding also occurs when converting double to a single precision value or floating point number to an integer Mmry Smrgm x uca IEEE FP Rounding Modes Examples Il l decimal but of course EEE754 Il l binary Round towards on a ALWAYS round up 2001 32001 2 Round towards W a ALWAYS round down 1999 a 1 1999 2 Just drop the last bits round towards 0 Unbiased default mode Midway Round to even a a rounding almos 24 2 26 325 235 A a Round like you learned in grade school nearestint a Except ifthe value is right on the borderline in which case we a This way hair the time we round up on tie the other halftime we roun down Tends to balance out inaccuracies MMW Smrgm xouca Peer Instruction 1000 0001 111 0000 0000 0000 0000 0000 What is the decimal equivalent of the floating pt above 75 7 zone a 129 2A7 MMW Smrgm xouca Peer Instruction Answer What is the decimal equivalent of S Exponent Significand 15 x 1 Significand x 2 EXP quot quotquot 27 11 x 1 111 x 2129427 1 x1111x2 2 731 7175 1111 3 7375 75 c 7 7 2A129 8 i129 2 7 MMW we u Peer Instruction Converting float gt int gt float produces ABC same float number Converting int gt float gt int produces same int number FP add is associative xyz x yz mdmmwaH 391 e e MMW Smrgm xouca Peer Instruction Answer 1 Fve fEt S1tEloat produces same float number 2 Fvek it Sat Ent produces same int number 1 314 gt3 gt3 2 32 bits for signed int but 24 for FP mantissa 3 x biggest pos yxz1xlnf 7 MP 8 TTT MMW Smrgm xouca Peer Instruction Letf12 of oats between 1 and 2 Letf 2 3 of oals between 2 and 3 1 f12 lt f23 2 f12 f23 3 f12 gt f23 MMW Smrgm xouca Peer Instruction Answer Let 15 12 of floats between 1 and 2 Let f 2 3 of floats between 2 and 3 1 f12 lt f23 CD4 l l l Fi l Fi ilii i H l l l gtw 2 f12 f23 0 3 f12 gt f23 39 39 anely Spring Znn ouca And in conclusion Reserve exponents significands Exponent Significand Object 0 0 0 0 nonzero Denorm 1254 Anything I fl Pt 255 Q I 255 nonzero M 4 Rounding modes default unbiased MIPS Fl ops complicated expensive 39 39 anely Spring Znn ouca Bonus slides These are extra slides that used to be included in lecture notes but have been moved to this the bonus area to serve as a supplement The slides will appear in the order they would have in the normal presentation Imus anely Spring Inn 22 uca FP Addition More difficult than with integers Can t just add significands How do we do it n Denormalize to match exponents a Add significands to get resulting one u Keep the same exponent n Normalize possibly changing exponent Note If signs differ just perform a subtract instead 39 39 anely Spring Znn ouca MIPS Floating Point Architecture 14 MIPS has special instructions for floating point operations a Single Precision adds subs muls divs a Double Precision addd subd muld divd These instructions are far more complicated than their integer counterparts They require special hardware and usually they can take much longer to compute 39 39 anely Spring Znn ouca MIPS Floating Point Architecture 24 Problems n It s inefficient to have different instructions take vastly differing amounts of time n Generally a particular piece of data will not change from FP to int or vice versa within a program So only one type of instruction will be used on it n Some programs do no floating point calculations n It takes lots of hardware relative to integers to do Floating Point fast 39 39 anely Spring Znn ouca MIPS Floating Point Architecture 34 MIPS Floating Point Architecture 44 1990 Solution Make a completely separate 39 1990 COmPlfter aCtually mains mu39tiPle chip that handles only FP separate chlps coprocessor 1 FP chip u Processor handles allthe normal stuff a contains 32 32bit registers f0 f1 coprocessor 1 handles FF and only FP a most registers specified in s and d instruction D more coprocessorSquot Yes later refer to this se a Today cheap ChlpS may leave out FP HW a separate load and store lwcl and swcl I Instructions to move data between main processor and coprocessors D n1ch mtcO mfcl mtcl etc load word coprocessor 1quot store quot a Double Precision by convention evenodd pair contain one DP FP number f0f1 f2f3 Appendix pages A40 to A44 contain f30 f31 many many more FP operations Mowery Smrgm xeuca Mowery Smrgm xeuca Example Representing 13 in MIPS Casting oats to ints and vice ve rsa 39 13 int floatingpointexpression 15625 o00390625 Coerces and converts it to the nearest integer C 14 116 164 1256 usesfruncatlon 212J2762 m L Lnt 314159 f 00101010101Z 2 111101010101Z 2392 Si n 0 float integerexpression u Examquotem 2 127 125 01111101 converts integer to nearest floating point a Signi cand 0101010101 f f float 1 0 01111101 01010101010101010101010 Mowery Smrgm xeuca Mowery Smrgm xeuca int gt oat gt int float gt int gt float 1f 1 intfloat 1 l 1f f float1nt f l puntf true puntf true Will not always print true Most large values of integers don t have Smaquot oating point numbers lt1 don t exact oating point representations have integer representations 39 What ab quott d Uble For other numbers rounding errors Will not always print true Mowery Smrgm xeuca Mowery Smrgm xeuca Floating Point Fallacy FP add associative FALSE u x 15x1033y15x1033 andz10 u x y z 15x1033 15x1033 10 15x1033 15x1033 M u x y z 15x1033 15x1033 10 00 10 ThereforeI Floating Point add is not associative u Why FP result apgroximates real result a This example 15 x 1033 is so much larger than 10 that 15 x 1033 10 in floating point representation is still 15 x1033 Mmry swgmnxeuca


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Janice Dongeun University of Washington

"I used the money I made selling my notes & study guides to pay for spring break in Olympia, Washington...which was Sweet!"

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.