Please help with decimal to floating-point conversion

  • Thread starter Thread starter neshepard
  • Start date Start date
AI Thread Summary
The discussion revolves around converting the decimal number -0.46875 to its binary floating-point representation using IEEE 754 format. The sign bit is established as 1 due to the negative value, and the binary conversion of 0.46875 is identified as 0.01111. Participants clarify the process of normalizing the binary number into scientific notation, resulting in 1.111 x 2^-2, and emphasize the importance of correctly determining the biased exponent. There is confusion regarding the placement of zeros in the mantissa and how it affects the biased exponent, with some contributors suggesting that zero-filling at the end is acceptable. Ultimately, the original poster confirms they solved the problem, but discussions indicate lingering uncertainties about the conversion process and formatting.
neshepard
Messages
67
Reaction score
0

Homework Statement


This is the number given to convert to binary: -0.46875. I need to find the biased exponent and the normalized mantissa in binary.

Homework Equations


The Attempt at a Solution


I am not a computer sci major, but have to take for my electrical engineering degree, and this is harder to me than physics and calc 2. Anyway...
Sign bit is 1 since it's negative, that much I know.

But from here out I'm wrong or lost.
No whole number so no way to find exponent?
.46875 = 01111000 in 8bit
no exponent because no whole number so I just use 127=01111111 in 8bit?
and then...
 
Physics news on Phys.org
I take it you are doing some form of IEEE 754? Single precision, maybe? Please confirm/elaborate.
 
Yes this is IEEE 754, for my intro to computer systems class. I have the steps all written down to solve it, but the numbers the professor gave in his examples are all 32 bit and the example is a fixed point 9 bit (plus a sign bit).
 
Not sure if I understand what the problem is - shouldn't you just fill up with zeros?
 
I managed to solve it. What he gave us is the adjusted mantissa. This meant to find the needed parts I had to both backwards and forwards work the problem.

As to Borek, that is part of the problem, can I just add zeros? Where do I just add them? At the back of the number it doesn't change the decimal but it changes how the whole number is used for the biased exponent. At the front of the number it changes the decimal part of the floating point part.
 
As far as I understand biased exponent is used for notation, for calculations/conversion you can "unbias" it. But then, can be I have a (relatively early) senior moment, but I fail to see how the fact that the exponent is biased changes meaning of ending zeros in mantissa.

.11*22 doesn't differ from .1100*22, biased mantissa means just that the number is multiplied by some power of 2.

Or am I missing something?
 
The first thing to do is convert 0.46875 to binary; you can do it by hand, or use a binary converter (I have one at http://www.exploringbinary.com/binary-converter/" ): 0.01111. Then, rewrite 0.01111 so it's in normalized binary scientific notation: 1.111 x 2-2. From there, using the definition of the IEEE format (single or double), you should be able to get what you need.
 
Last edited by a moderator:
I have a feeling that you posted just to promote your site, as you have not addressed OP doubts - in fact, your answer have ignored them completely.
 
Last edited:
OP seemed to have trouble arriving at the biased exponent. This problem is all about following specific steps which OP has not shared clearly in order to see if there is a misunderstanding or not. What Dr. Binary is saying is correct and is a prerequisite for calculating the correct biased exponent. Web site may be a self-promotion, but honestly, it's kinda neat (the Windows Accessory Calculator can't deal with fraction->binary). Zero fill on the back of the number is fine, but It's not clear what OP is concerned about. Glad to see that OP solved it. What was the OP's final result? The following suggests there still may be some confusion:

I managed to solve it. What he gave us is the adjusted mantissa. This meant to find the needed parts I had to both backwards and forwards work the problem.

As to Borek, that is part of the problem, can I just add zeros? Where do I just add them? At the back of the number it doesn't change the decimal but it changes how the whole number is used for the biased exponent. At the front of the number it changes the decimal part of the floating point part.
 
  • #10
I "promoted" my binary/decimal converter because it's the only one I know of that can handle fractional binary values (to arbitrary precision). I could have pointed the OP to one of those converters that convert directly to IEEE format, but I thought that would have been "cheating." I thought making the OP think about binary scientific notation -- which by the way, I have an article about, but which I DIDN'T promote :) -- would help him reason through the question.

Maybe the OP can tell me if I helped or not? If not, I'd be happy to try again.
 
  • #11
From what I understand OP didn't have a problem with finding mantissa (see the very first post, where mantissa is already calculated), but with storing it in the 32 bit format (as mantissa is much shorter than its field, 4 bits vs 23 bits).
 
Back
Top