9 Replies - 1955 Views - Last Post: 28 April 2010 - 02:31 PM

#1 Guest_brock*


Reputation:

decimal to floating point

Posted 26 April 2010 - 12:38 PM

convert 3.4375(decimal) to an 8-bit floating point binarty patter that uses 1 bit for the sign, 3 bits for the exponent(excess-4 notation), and 4 bits of rthe manitssa.


No votes

Answer 3 Accept Answer Reject Answer

for number 3 what I did so far is the mutliplication of the decimal point by 2( ex. 0.4375 x 2=0.875, 0.875x 2= 1.75 .....). So 0.4375=.0111 and 3.4375= 011.0111, now I am stuck now with normalizing the number and so forth. what I understand about normalzing is that the dot has to be 1 bit from the left, but if I do this I get 0.110111.

Is This A Good Question/Topic? 0

Replies To: decimal to floating point

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13492
  • View blog
  • Posts: 53,895
  • Joined: 12-June 08

Re: decimal to floating point

Posted 27 April 2010 - 07:18 AM

View Postbrock, on 26 April 2010 - 01:38 PM, said:

convert 3.4375(decimal) to an 8-bit floating point binarty patter that uses 1 bit for the sign, 3 bits for the exponent(excess-4 notation), and 4 bits of rthe manitssa.


No votes

Answer 3 Accept Answer Reject Answer

for number 3 what I did so far is the mutliplication of the decimal point by 2( ex. 0.4375 x 2=0.875, 0.875x 2= 1.75 .....). So 0.4375=.0111 and 3.4375= 011.0111, now I am stuck now with normalizing the number and so forth. what I understand about normalzing is that the dot has to be 1 bit from the left, but if I do this I get 0.110111.


I vote reject answer! Oh.. wait.. I can't vote? What sort of constitution are we operating under?!
Was This Post Helpful? 0
  • +
  • -

#3 Guest_brock*


Reputation:

Re: decimal to floating point

Posted 27 April 2010 - 04:43 PM

if someone can please help me
Was This Post Helpful? 0

#4 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2014
  • View blog
  • Posts: 5,395
  • Joined: 27-December 05

Re: decimal to floating point

Posted 27 April 2010 - 08:53 PM

View Postbrock, on 26 April 2010 - 03:38 PM, said:

what I did so far is the mutliplication of the decimal point by 2( ex. 0.4375 x 2=0.875, 0.875x 2= 1.75 .....). So 0.4375=.0111 and 3.4375= 011.0111, now I am stuck now with normalizing the number and so forth. what I understand about normalzing is that the dot has to be 1 bit from the left, but if I do this I get 0.110111.

Your "result" (so far) is correct but for the wrong reason. Decimal 3.4375 converted to binary is 11.0111 (forget about any leading 0). Normalizing it involves moving the radix point to the left of the first non-zero digit. How far you move it determines the exponent. Which direction you move it determines the sign of the exponent.

Now you continue ...
Was This Post Helpful? 1
  • +
  • -

#5 Guest_brock*


Reputation:

Re: decimal to floating point

Posted 27 April 2010 - 09:51 PM

So 11.0111 turns into .110111 . Now the radix was moved two times which in excess notation is 110. So the sign bit is 0 the exponent is 110 and the mantissa is 1101, so all together it is 0 110 1101. But the asnwer is 0 110 1110
Was This Post Helpful? 0

#6 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2014
  • View blog
  • Posts: 5,395
  • Joined: 27-December 05

Re: decimal to floating point

Posted 27 April 2010 - 10:42 PM

Looks like whoever wrote that "answer" got it wrong. Either they have the mantissa before the exponent instead of after, or they screwed up in calculating the mantissa.


...or maybe not. See post below.

This post has been edited by r.stiltskin: 28 April 2010 - 02:06 PM

Was This Post Helpful? 0
  • +
  • -

#7 Guest_brock*


Reputation:

Re: decimal to floating point

Posted 28 April 2010 - 09:28 AM

so is 0 110 1101 correct then because 0 110 1110 is the answer my prof gave us.
Was This Post Helpful? 0

#8 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2014
  • View blog
  • Posts: 5,395
  • Joined: 27-December 05

Re: decimal to floating point

Posted 28 April 2010 - 10:46 AM

I guess you should assume that your prof's answer is correct. ;)

I'm not just being facetious. I think I see what's happening. First of all recognize that this algorithm isn't what is generally used to represent floating point numbers on real, modern computers. In most cases they follow the IEEE754 standard -- you can google that for details. What you're using is a simplified algorithm for teaching purposes, and different versions are used at different schools. In the ones that I've seen before today, any "extra" digits in the mantissa are simply truncated, so .110111 becomes .1101 if only 4 digits can be used. But rounding, rather than truncating the extra digits is also a valid approach and arguably more accurate than truncating. So, since .110111 is closer to .1110 than it is to .1101, it seems that your professor is rounding rather than truncating the result and under that assumption .1110 is correct for the mantissa, and 01101110 is correct for the entire number.
Was This Post Helpful? 0
  • +
  • -

#9 Guest_brock*


Reputation:

Re: decimal to floating point

Posted 28 April 2010 - 02:05 PM

is this because .110111 equals 55/64 and .1110 = 52/64 and .1101 = 50/64.
Was This Post Helpful? 0

#10 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2014
  • View blog
  • Posts: 5,395
  • Joined: 27-December 05

Re: decimal to floating point

Posted 28 April 2010 - 02:31 PM

View Postbrock, on 28 April 2010 - 05:05 PM, said:

is this because .110111 equals 55/64 and .1110 = 52/64 and .1101 = 50/64.

You have a couple of mistakes there. But an easier way to see it is:

0.110111
+.000001
0.111000


0.110111
-.000011
0.110100

So rounding up means adding only 0.000001 (1/64) whereas truncating means subtracting 0.000011 (3/64).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1