Machine Structures COMPSCI 61Cl
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
Are you sure you want to buy this material for
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'