# Homework Help: Please help with decimal to floating-point conversion

1. Sep 16, 2010

### neshepard

1. The problem statement, all variables and given/known data
This is the number given to convert to binary: -0.46875. I need to find the biased exponent and the normalized mantissa in binary.

2. Relevant equations

3. 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.......

2. Sep 16, 2010

### lewando

I take it you are doing some form of IEEE 754? Single precision, maybe? Please confirm/elaborate.

3. Sep 16, 2010

### neshepard

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).

4. Sep 17, 2010

### Staff: Mentor

Not sure if I understand what the problem is - shouldn't you just fill up with zeros?

5. Sep 17, 2010

### neshepard

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.

6. Sep 17, 2010

### Staff: Mentor

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?

7. Sep 17, 2010

### DoctorBinary

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/" [Broken]): 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: May 4, 2017
8. Sep 18, 2010

### Staff: Mentor

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: Sep 18, 2010
9. Sep 18, 2010

### lewando

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:

10. Sep 18, 2010

### DoctorBinary

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. Sep 18, 2010

### Staff: Mentor

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).

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook