You are on page 1of 24
ise ‘sSlence Floating point form You have seen how a real number can be represented using a fited numberof bits. This Is known a fxd int peasantalon In fod pont representation, the binary point is st in ‘a specie place and so he allocation of the bits between te whole part and factional part cannot change, There a ade of between the numberof bls allocated to each part. A larger numberof bts for the whale part will allow very large values to be represented, but without the detail ofthe fractional part. A tars numberof bts forthe ractonal part will allow very small and increasingly precise values to be represented after the binary point, but the whole part will be constrained to small numbers. Ifthe par, the number may need tobe buncz a inufficent bis in either ‘hon dealing with very large or very small numbers, a more lexbe technique, known as floating point representation, can be employed. Tis allows the way thatthe bits are allocaod to vary so tat both vory lage and vary small numbers can be reprasonted. Floating point representation Binary ating point numbers are expressed inthe form mantissa x "7", og (0.101 x2*, Here, the mantissa is 0.101 and the exponents 4. By defiriton, the ‘umber base ofa binary numbers always 2. ‘You may recognise tis way of representing numbers ae scientific notation or ‘standard form. For example, in denary, the number 0.000790 can be wsiten in standard form as 7.9% 10 Hera, 7.9 isthe mantissa and ~t isthe exponent. By definition, the number base of a denary numbers alvays 10, Atloting point numb the exponent, in binary consists of bits allocated to store the mantissa and ' The number basis not stored, as itis always 2 + The binary pointe also not stored: itis always found inthe same place Immodiately after the fist bit * Imexam questions, the allocaton ofthe numberof bis forthe mantissa and the ‘exponent snot fixed: for example, you might bo asked to representa oating Point number using 8 bis forthe mantissa ard 4 bits forthe exponent, whl in ‘another question be asked to use 7 bits forthe mantissa an 3 forthe exponent. In computer systems how floating point numbers are represented depends on the system's architecture Ite binary number 0.101 x 2 is stored in a format that allows 8 bts for the mantissa and 4 bits forthe exponent it would be stored as a 12, number as shown below. Mantssa Exponent o 1 0 o 0 06 © 9 1 6 0 ‘This canbe invepreted as 0.101 x2* (when the exponents converted from binary to onary) The huss complement representation is used for both the mantissa and the ‘exponent The two's complement mantissa allows positive and negative values to be ‘store, The two's complement exponent allows both postive and negative exponents tobe stored, which means that very large and very smal values canbe represented, Throughout this topic wo wil show the binary pont in lating point numbers (to remind you whore its), We wil also show the two's complement place values For ‘example, for 0.101 x2# the place values ar presented below. Mantissa Exponent Converting a binary floating point number into denary Method 1 - Using the numerical expression ‘One way to convert floating point binary number into danary Is to use the ‘expression mantissa » 25°" and evaluate each par of i aking into Consideration that both the mantissa and the exponant are represented in ‘two's complement Inthe fallowing example, the Mloating point number 101100000010; is represented sing 8 bits forthe mantissa and 4 bits for the exponent Mantisss Exponent tot aon 42 1 oo o 0 0 0 oo ° Using he place values, you can determine that he ‘andthe donary value of the mantssa is 1 + ary value of exponent is 2 0.625, “The vai ofthe number in donary can be caleulted a8 ~0.625 2? = 25, Embedded YouTube video: hips:wwyoutube.comiwatch?y=9VbxP6POk. Try it yourself! ‘The binary number shown is encoded as a floating point number with a 7-bit mantissa and a S-bit exponent. The mantissa and exponent are both stored using two's complement. Mantissa Exponent Convert the number to denary. Click a button to show the answer ‘Whats your love of confidence that your own answers correct? low Medium Method 2 - Shifting the binary point ‘Another way to conver a leating point number into denary isto use the value ofthe ‘exponent to move the binary point. The mantissa represents a value with a binary point otwean the two most significant is. The exponent determines how far to Nat the point to determine th final value ofthe number. + ithe exponent is postive. the fina value wil be larger than the mantissa, so the point wl tat to th right — the numberof places it wll move ls determined by the value ofthe exponent += Ifthe exponent is negative, the point wil oat to the let — forthe number of places determined by the exponent Hore are some examples to Musrate i: Example 1: positive mantissa, positive exponent {Conver 0100010001012 to denary, The mania is 8 bts and the exponents ts. Step1 ‘Write down the place values fr the mantisea andthe exponent in two's complement were the mast significant bt determines te sign ofthe number, Mantissa Exponent boat aoa 42 ° 10 9 09 1 6 6 ° oo Step2 Find the value ofthe exponent; here itis +5. “ 4 2 1 Step 3 ‘The exponentis positive, 0 move the binary pont § places to the right. Then caleulate the sumber using the place values table in the same way as for ‘ix paint binary. (010001.003 = 1176 2 boos 4 Embedded YouTube video: ipsshwn youtube comwatch?¥=E Try it yourself! DTHyLyBl. ‘The binary number shown is encoded as a floating point number with a 7-bit mantissa and a S-bit exponent. The mantissa and exponent are both stored using two's complement. Mantissa Exponent Convert the number to denary. Click a button to show the answer Whats your love of confidence that your own answers correct? low Medium Example 2: positive mantissa, negative exponent Convert 010100001111, to denary. The mantissa is 8 bits and the exponent is 4 bits. Step1 ‘Write down the place values fr the mantissa andthe exponent two's complement were the most significant bit determines the sign ofthe number. Mantissa Exponent Step2 Fin the value ofthe exponent here itis ~ 4 Step 3 ‘The exponentis negative, so move the binary poin 1 place to the left. Note that, ‘because the mantissa is postive (meaning the number is postive), you need to In wth leading zeros as you move the binary point othe let. Then calculate the ‘umber using the place values table in the same way as fr fixed paint binary, 0.1010000 becomes 001010003 = +0:312510 Embedded YouTube video: hips: /hw youtube.comiwatch?¥=/ Try it yourself! ‘GondgmtJRO, ‘The binary number shown is encoded as a floating point number with a T-bit mantissa and a 5-bit exponent. The mantissa and exponent are both stored using two's complement, Mantissa Exponent oOo. 1 1 0 0 0 0 4 1 tod Convert the number to denary. Click a button to show the answer Whats your level of confidence that your own answeris corect? low Medium High Example 3: negative mantissa, po: e exponent ‘Convert 10111100001; to denary. The mantissa is 8 bis and the exponents 4 bs Step1 ‘Write down the place valu fr the mantsta andthe exponent in two's complement, vera the mast significant bt determines the sign ofthe number, Mantissa Exponent “1 bad Boh os 4 2d 1 o4 L o 4 oo 1 Step2 Find the value ofthe exponent; here is 3 4 2 ' Step 3 ‘The exponentis positive, 5 move the binary poi 3 places to the right. Then caleulat the number using the place values table in tho same way as for {xed point binary. 101.1100, 4.2510 Embedded YouTube video! hips: youtube comvatch?v=vGASPFOZHD Try it yourself! The binary number shown is encoded as a floating point number with a 7-bit mantissa anda 5-bit exponent. The mantissa and exponent are both stored using two's complement. Mantissa Exponent Convert the number to denary. Clicka button to show the answer O Whats your level of confidence that your own answers correct? low Medium High Example 4: negative mantissa, negative exponent ‘Convert 101000001110, to denary. The mantissa is 8 bits and the exponent is 4 Bits. Step1 \Wrte down the place values fr the mantissa andthe exponent in two's complement ere the most significant bit determines te sl ofthe number. Mantisss Exponent ban 421 Step2 Find the value ofthe exponent; here iis 2 “8 4 1 Step 3 ‘The exponentis negative, so move the binary point 2 places to the left. Note that because the mantissa is negative (moaning the number is negative), you raed to ‘iin wth leading ones as you move the binary pont othe lf. Then calculate the umber using the place values table in 1 18 Same way as for fixed-point binary, 1.010000, becomes 1.110100000; O18TS Enieded YouTube vdeo: hipsmw.youube comnichv-iuPg_bO14 Try it yourself! ‘The binary number shown is encoded as a floating point number with T-bit mantissa and a 5-bit exponent. The mantissa and exponent are both stored using two's complement. Mantissa Exponent Convert the number to denary. Clicka button to show the answer in Whats you lovel of confidence that your own answers correct? low Medium High Normalisation of floating point numbers The normalised version ofa fractional number provides @ unique representation for ‘a number and allows the maximum possible precision with a given number of bis. Therefore it's very useful when working with very large or very smal numbers. Its the equivalent ofthe standard form for denary numbers. For example, 9.25710 can be represented with 4 agits as below + 9,2579 «10° + 925.71 * 10 #92570 * MF + 9.25%. * 10° ‘Only he lst example is represented in standard form (the dig befor the decimal points between 1 and 9). Similar, suppose you want to represent ~0.046875p as a binary flating point umber. Here are some examples ofthe way tha he value can be represented: + Linon x28 + Linon x2" = Lio x2? 11012? lore All ofthese examples represent the same value (-0.046875}0), but ony th final ‘example is normalised. You cannot shit the binary pent again or the value of the ing 0} ‘Therafore, the normalised version of the number provides a unique representation of ‘umber wll change (t would appear to be postive as it would have that number. ntis caso, al leadings son the negative number have been removed, the number tobe represented Is postive all/sading O's would be + Tho normalised version of a positive fractional number has ne leading zeros, after the binary point — a normalised positive number always starts a 0.1 + The normalised version of a negative fractional number has no leading ones. after the binary point — a normalised negative number always stats as 10 Moreover, the mantissa of a floating point number holds the significant bits of that number, Le the detail ofthe value ofa number. Tis means that when you need to store very precise fractional numbers, you benef from having ls of bits aftr the binary point. you had 8 bis fora number's mantissa then the normalised version ‘would allow 7 of the & bs to be used after the binary pont, Thats why wit ‘rmalisation, you can achieve the maximum possible accuracy fora specific number ofits, How to normalise a floating point number 1. To normalise a flaatng point binary number, you need to check whether the rumieris postive or negative by checking the sign af the mantissa, and act as. follows: «= Ifthe number is positive, you need to move through the mantissa from lft to right unt you find the frst bt whose value is 1. The binary point wil be postioned immediatly in front ofthis bit. A normalised postive number always starts as 0.1 += ithe number is negative, you need to move through the mantssa from left to Fight unt you find the fs bit whose value is 0, The Binary point wil be positioned immediatly in trot of tis bit. A normal always starts as 1.0 14 nogative number 2. tor you move the binary point, you must adjust the exponent so that Ue value ofthe number remains the same, ‘+ Moving the binary point one place to the right equal to a tft shit that ‘muitipties the number by 2 Hence, you need to compensate by dividing the number by 2, which you can do by reducing the exponent by 1 ‘= Moving the binary point one place to the lofts equal oa right shit that divides the number by 2. Hence, you need to componsate by multiplying the number by 2, which you can do by increasing the exponent by 1 Here are some examples to sate these principles, Each example uses an 8-bit manta and 24: exponent: Example 1: positive mantissa - moving binary point right Normalise the lating point number with mantissa = 0.001011 and exponent = ols Mantissa Exponent - bo n a 424 ° oo 09 1 Oo 1 4 ° oo Step1 “The mantissa is postive, so we calculate how many places you need 'o move the binary point so that sits ust before the frst n thie cage the binary point has to ‘mave 3 places tothe right; 0.000011, + 0000.1011s Now you can discard aleading 0's excopt for the one immeclatoly before the binary point; 0000.01 y 0.10143 Pad the mantissa with 0's othe quired length (in this example we have an 8 bit smantisea); 0.101 1p + 0.101000, ‘Tho normalisod mantissa is 0.1011000; Step2 |As you have increased the value ofthe mantissa (by moving the binary point 3 places ight), you need to decrease the exponent by 3 to kesp the value of the number ‘he same, The new value ofthe exponent is 5—3 = 2y. Hence, the normalised umber is + mantissa =0.1011000; expone 0105 Mantissa Exponent Example 2: negative mantissa - moving binary point right Normalise the lating point number with mantss oo 11110013 and exponent = Step1 The mantissa s negative, so wo calculate how many places you need to move the binary point so that sits ust before the frst 0. nthis case the binary point has to ‘move 4 places to the right; 111110013 ~+11111.0013, Now you can discard al leading I's except forthe one immeciately before the binary point 1111.00» 1.00%. Pact the mantissa with 0's othe quired length (in ths example we have an & bt ‘mantissa; 1.0013 -»1,00100003 ‘The normalised mantissa i 1.001000, Step2 [As you have increased the value ofthe mantissa (by moving the binary point 4 places to the right), you need to decrease the exponent by 4 to keep the value of the number ponent fs 1-4= ~3,y, Honce, the normalised the same, The new value of th umber it ‘= mantissa = 1.0010000; exponent = 11013, Example 3: positive mantissa - moving binary point left Normals the lating point number wih mantss 1100, 100.0111; and exponent Step1 “The mantissa is postive, so we calculate how many places you need to move the binary point so that sits ust before the frst I. nthis case the binary point has to ‘move 3 places to the left 100,011 ~» 0.10001 13. ‘There are no extra 0's before the binary point o discard and you donot need to pad ‘he mantissa with 0's (as itis already the correct length). The nomalsed mantissa is .10001115 Step2 [As you have decreased the vale of te mantissa (by moving the binary point 3 places tothe lt), you need te nerease the exponent by 3 to keep the value ofthe 1p. Honce, the ‘umber the same. The new value ofthe exponents ~4 + rormalised number i ' mantissa = 0.100011, exponent= 11113 Example 4: negative mantissa - moving binary point left Normals the floating point number wih mantissa = 111101112 and exponent = Holy Step1 “The mantissa is negative, s0 we calculate how many places you need to move the binary point so that sits ust before the frst 0. n this case the binary point has to ‘mave 4 place tothe left; 11110.1112 + 111101113 Now you can discard alleading I's excapt forte one immecatoly before the binary point 111101113 + 1.01113 Pd the mantissa with 0's othe required length (in ths example we have an 8 bit smanissa); O11; ~ 101110003 The normalised mantissa is 1.011000; sed the value of the mantissa (by moving the binary point 1 places tothe lf), you need to increase the exponent by Ito keep the value ofthe ‘umber the same. The new value ofthe exponent is ~3 + 1 =~2yo. Hence, the ‘normalised number is ‘mantissa = 1.01112 exponent = 1110; Try it yourself! Each of the floating point numbers shown below has a 8-bit mantissa and a 5-bit exponent; both mantissa and exponent are represented using two's complement. State whether (or not) each number is normalised. Ifthe number is not, normalised, state how the mantissa and exponent must be adjusted, Mantisse Exponent ao. 0110101 OO O11 bo. 0001 1 1o FO 1 dt a 0 1000000 00001 d 1 1000101 O08 O11 21 orto 11 t 0 0 10.0 no1 Piitrori ooo118 Click a button to show the answer Whats you lovel of confidence that your own answeris correct? low Medium High Try it yourself! ‘The following number is represented in floating point form with 7 bits for the mantissa and 5 bits for the exponent (both in two's complement), The number is natnormalised. Mantissa Exponent o . 0 0 0 11 0 oo 11 7 Normalise the number by making the necessary adjustments to the mantissa and exponent. Click a button to show the answer Whats your level of confidence that your own answeris corect? low Medium Converting a denary number into floating point binary ‘To convert a denary number to floating point binary, you mus frst convert itto a {xed polnt binary number. Inthe materials for xed pont binary you saw how the onary value +4125, was converted to O1110.0013 + The leading zero is important asthe number s postive. ‘The number can be expressed as 01110.001> x 2°. The mantissa is 0110.00 {as the mantissa represents the actual value ofthe number) and the exponent Is (a8 2" = 1), ‘The next step isto normalise the number «+ Hare, the binary pont naeds to be maved four places tothe left, 01110,0012 —+ 0.111001 ‘Now you must adus the exponent so thatthe value ofthe number remains the same. You have moved the binary point to the lef by 4 places, so you must ad 4to the exponent Ths makes the exponent 0 4=4 ‘The binary number can now be expressed as 0.11100012 «24 IFthe number is stored in a format that allows @ bts forthe mantissa and 4 bts fr the ‘exponent, til be stored as shown below: Remember that he binary paint in a ‘ating paint number snot stored buts always found in the same pa immediatly ater the frat it. Also, both mantssa and exponent are repr ‘wo's complement Mantissa Exponent Inallof te example hat flow the numbers wil be sored in foatng pon fom with an bit mantissa anda 4b exponen, both vals are represented In Wo's complement Converting a positive denary value to floating point form Consider the denary value +9.75 (+93 or +38) Step Convert the value to two's complement fxd paint inary 2 bo os 4 2 4 5 ° ° ooo 4 boon Step2 Normalize the number ‘The binary value you have for 9.75 i 001001.11. The can be expressed as oor001.1t «2°, ‘The binary pont neads tobe floated tothe lf ofthe ist | (as the number fs postive) loft. Al leading 0's apart trom th fist must be discarded, hich is 4 places tothe (o01001.11 = 0.100111 Step 3 Encode the exponent 'As we moved the binary point othe lft by 4 we need to Increase the exponent by 4 ‘The exponent becomes 0-+4= 4. The exponent, Ike the mantissa, isn two's complement so must be stored with leading ero ta show that itis a posive umber Step 4 Finalise the result ‘You can now complete both mantissa and exponent. The mantissa can be paced to the ight with 0's as this doos net affect the place value ofthe significant dts. Mantissa Exponent a aot Som S42 ° to o t toto ° oo Embedded YouTube video: hips youtube.com atch ?v=#BOHF BBO Try it yourself! Convert the denary number +17.5 (174 or 3) into binary using normalised floating point representation with 8 bits for the mantissa and 4 bits for the exponent, both expressed in two's complement, Click a button to show the answer Whats your level of confidence that your own answeris corect? low Medium High Converting a small positive denary value (<1) to floating point form Consider the donary value ~0.046875 (= Step1 Convert the value to two's complement fixed point binary 6.046875 fecuvalentso (0.03125) +: (0018625) Step2 Normalise the number “The binary value you have for +0.046875 is 0.000011. This can be expressed as 6.000011 x2° ‘The point needs o be oated to the let ofthe mast sightficant I (asthe number is posive) which is four places tothe right. leading U's apart from the first can be iscarded. 0.000011 — 0.11 Step3 Encode the exponent 'As we moved the binary pint othe right by & we 4. The exponent becomes 0 1 to decrease the exponent by “4 Step 4 Finalise the result ‘You can now compte both mantissa and exponent. The mantissa can be padded to ‘he right with 0's as ths does not fect the place value ofthe signiicant digits. Mantissa Exponent Try it yourself! Convert the denary number +0.375 (3) into binary using normalised floating point representation with 8 bits for the mantissa and 4 bits for the exponent, both expressed in two's complement. Click a button to show the answer Whats you lovel of confidence that your own answeris correct? low Medium Converting a negative denary value to floating point form Consider the denary value -29.25 (-294 or —22) Step? Convert he value o fwo's complament fixed pant binary ‘You can use any ofthe three methods that have been descrned. The following ‘example uses the method Flip the bits othe lef ofthe least sigifcant 1" 2 ow 8 4 1 Normalize the number ‘The binary value you have for -29.25 is 1010.11. This can be expressed a og010.11 «2°, The binary point needs tobe loated tothe laf ofthe most significant 0 (asthe ‘umber is negative) whichis S places to the lft. 100010.11 -» 10001011 Step 3 Encode the exponent [As we movad the binary point othe lft by 5 we need to increase the exponent by 5 ‘The exponent becomes 0-+$= 5. The exponent, Ike the mantissa isin W's complement so must be stored with a leading ora to show that itis a postive umber. Step & Finalise the sult ‘You can now complete both mantissa and exponent. The mantissa can be padded to the right with 0's as this doos not affect the place value of the sigiicant digs. Mantissa Exponent “1 ad a a 424 1 oo 0 1 oO 1 4 ° 04 Embedded YouTube video: hips: youtube.com watchV=ESNSMgpswVg Try it yourself! Convert the denary number 17.5 (-17 or 35) into binary using. normalised floating point representation with 8 bits for the mantissa and 4 bits for the exponent, both expressed in two's complement. Clicka button to show the answer in Whats you lovel of confidence that your vn answers correct? low Medium High Converting a small negative denary value (<1) to floating point form ‘Consider the denary value ~0.625 (-$) Step1 Conve the value ofos complement xd pon binary ‘You can use any ofthe three methods that hava been described. The folowing lof ofthe leas significant 1" ‘example uses the method “Flip the bts to th 0.625 is equivalent to §(0.5)+ $ (0.125) 40.625 ° 1 ° 1 0.628 ' 0 1 L Step2 Normalize the number “The binary value you have for~6.25 is |.011, This can be expressed as 1.011 x2" ‘The ponlis akeady in the correct place -to the fof the most signicant 0 (as the ‘umber is negative)- 50 It does not need o be moved, Step3 Encode the exponent sxponent is 0 (asthe point dd not need tobe moved). Step 4 Finalise the result ‘You can now compete both mantissa and exponent. The mantissa can be paced to ‘ho right with 0's as ths doos not afect the place value of th signiicant digits. Mantissa Exponent “1 ao Boho fad 1 v4 o 0 0 6 oo oo Try it yourself! Convert the denary number 0.375 (-3) into binary using normalised floating point representation with 8 bits for the mantissa and 4 bits for the exponent, both expressed in two's complement. Click a button to show the answer Whats your lovel of confidence that your own answeris correct? low Medium High Useful tip [Another way to conver a derary fraction ito @flstng pont binary numbers by sing the numerical expression mantissa x 2°" For example, consider converting int lating point wit 8 bls fr the mantissa ‘and 4 bits forthe exponent 1 This number can be expressed inthe form mantissa x 2°" as flows: £a5ehe5xo4 12 mantissa int binary; 01010000, « 2+ ' Normalise the number by moving tho binary point 3 places to the oft and increase the exponent by 3(— + ), 101.0000; « 2° = 0.101000 «27 * Express the fnal result binary (0.1010000; » 2" in binary, with mantissa = 0.1010000s and exponent = L112 Mantissa Exponent ° 104 Afinal note ‘The process of converting a denary number to floating point binary wil ake practice. ‘Romember that you can conver it back to danary to make sure thal you have done i correctly, You can also “sons check” the nal sul Here are some useful fact for ‘normalised lating point numbers. Final result Postve mantissa and positive exponent Postive mantissa and negative exponent Negative mantissa and positive exponent Negative mantissa and negative exponent ‘Tho donary value wll be postive ane grater than orequalto I (e.g. 38.128) The denary value will be postive and less than 1 (9.0375) The denary value willbe negative and greater than or equalto I (e9.~265) ‘The denary value wil be nagative and and ess than 1 (eg. ~0.0675) Overflow and underflow Overflow ‘Overflow occurs when the result ofa calculation is too large to be represented with the available number of bits For example, overflow can occur due to addon of two numbers of the same sign: both numbers are poste, a larger umber may be produced, while when both ‘numbers are negative, a very small negative number may be produced; eter of these new numbers may need more bits than are available tobe represented In normalised floating point representation using 8 bis (4 bts forthe mantssa and & bits forthe exponent), the largest positive number the postive number thats furthest away rom zero) that canbe represented is 0, 11101112 = 2 x2? Mantissa Exponent ‘The smallest negative number {.e.the negative number that is furthest away for 2010) that canbe representad using 4 bits for the mantssa and bits fr the ‘exponents 1.000011 fp ==1 x2" Mantises Exponent 4 ou 2 1 o 0 oO oo bo. With the given number of bits, any number that exceeds one of these two Values results in overtiow. Underflow Underflow occurs whan the result af a calculation is too small. itis too close to zero, to be represented with the avallable number of bts. For example, undertow can occur due fo subraction of two numbers with similar values and the same sign: when subactng two postive numbers that ae close in value, the result may a number very near to 220, In normalise floating point representation using 8 bits (4 bits or the mantissa and 4 bits fr the exponent), tho smallest positive number. tho postive value that is closest lo 2070} s 0.100100 = $ x 2-*, Note that, because of roemaistion, the be 0.001, mantissa cann Mantissa Exponent “ hou oo2 04 a oo 1 0 8 0 ‘The largest negative number (Le. the negative value that is closest to 20) that can be represented using 4 bis for the mantssa and 4 bits fr the exponent is 1.0111000: Exponent “ bobo? 42 o 1 4 oo With the given number of bits, any number that exceeds one of these two values can result in underflow. Adding floating point numbers Before performing addition of eating pont numbers, you need to ensure thatthe ‘umbers are normalised and that ther exponents are the same. Then you can add ‘ha mantissas together and, ifncessar, normalise the result to ge the nal number Example + Using 8 bits forthe mantissa and 4 bits forthe exponent, add the numbers 101110101113 and 0111100001013 += Beth the mantissa and the exponent are represented using two's complement * The rest ofthe addition should be in normalised floating pont representation Step1 First, check whether the numbers ae normalised. Sth numbers start with, ‘meaning they are normalised and the binary points right aftr the fst binary dit + o1oiuio101nty + 11110000101; soinio10111, 111100001012 Step2 ‘Separate the mantssas rom the exponents + 0.1011701011 13 - manasa is0.1011101 exponent is 01112 vals f 0.102110 + 0.11110000101) - mantissa is 0.1111000 exponentis 0101) valu is 0.1111000 [Check whather the exponents ofboth numbers are the same. The exponents here ‘are diferent, so you need to change the smaller exponent to match the ger one. ‘Shift the binary point of the second number two positions tothe left, and increase the exponent by 2 + 0.1111000 «2° = 0.001111000 x27 Step3 ‘Once the exponents are the same, ad the mantssas. ‘Adstion of foting point umes flows the same rules a8 addition of unsigned integars: ad up the bis that belong tothe same place value column and leave the binary point tween the fist wo digs. ° roo Fo to do 4 + ° oo 1 tot 4 6 carry ord result 0 rororot oe rot Note that you truncated the trang zeros tht exceeded the 8 bis used for the ‘mantissa; this does not affect the end result Step 4 ‘The results 01111011 x27 ands akady normalised. You can double-check the resullby converting into danay: OAO111012 «27 = 93,0 0.00111103 «2? = 10 0.11110113 x2? = 123% Subtracting floating point numbers ‘To subtract one postive floating pont rumber from another, you conver the secand ‘umber (the subtraheng) nto a two's comploment negative value and then add the ‘wo numbers together using floating point adsiton. This is because calculating umber - number iste same as number + (-number2) Example + Subtract 0111100000013 from 0101000100113 '= The mantissa is 8 bis and there are 4 bits forthe exponent; both the mantissa and the exponent are represented using two's complement * The res ofthe subtraction should bein nomalse floating point representation Step {Check whether both numbers ara normalised. Her, both numbers stat with 01 ing thay ae normalised. Remambar thal the binary points nat stored but i Straight ator te rst eigit + 0101000100113 = 0.101000100113, + 011110000001, = 0.111100000013 Step2 ‘Separate the mantssas rom the exponents + 010100010011: - mantissa f 01010001 exponentis 001 1a the value is 0.10100012 x2 + 0111100000012: mantisa s 0.111000 exponent is 00012 - he values 0.111100; «2 Step 3 {Check whether the exponents ofboth numbers are the samo, This snot the case here, so change the smaller exponent to maich the larger one. Shi the binary point fhe second nube: two positions to the lft and increase the exponent by 2: + 0.111000 x2 = 0.001110 x2" Step 4 Find the negative value ofthe second number. Calculate the atve value of the number, for example by ipping each bit and ‘hen adsing 1 tothe number. ° oo 1 bot do fipthe bis 1 1 1 0 6 9 oO 8 ada ' any 1 1 1 1 0 6 © 1 0 Steps Perform the subtraction by adding he two mantssas, Ignore the cary 1 overtiow carry 1 resut 40 o 1 1 Oo o 4 4 Step 6 ‘The results 0.011001 x2, Normals it by shifting the binary point one position to the right and decreasing the exponent by one. + oo1100113 x2? 1001103 x22 Step? ‘You can double-check te result by converting into donary 0.10100013 x2* 1962510 : (0.1111000; «2! = 1.875_10 0.11001103 x2 1875_10 [Aeachna mtr on sl a avlabeundarth Opan Covariman Lennon v2.0, excep ahs abr ti,

You might also like