Please help with decimal to floating-point conversion

  • Thread starter Thread starter neshepard
  • Start date Start date
Click For Summary
SUMMARY

The discussion focuses on converting the decimal number -0.46875 to its binary representation using IEEE 754 single precision format. The sign bit is established as 1 due to the negative value. The normalized binary scientific notation for 0.46875 is determined to be 1.111 x 2^-2, leading to a biased exponent of 127-2=125, represented in binary as 01111101. The conversation highlights the importance of understanding how to manipulate the mantissa and exponent in the context of floating-point representation.

PREREQUISITES
  • Understanding of IEEE 754 single precision format
  • Binary conversion techniques for decimal fractions
  • Knowledge of normalized binary scientific notation
  • Familiarity with biased exponent calculations
NEXT STEPS
  • Learn about IEEE 754 double precision format
  • Explore binary conversion tools, such as the one at http://www.exploringbinary.com/binary-converter/
  • Study the implications of zero-padding in floating-point representation
  • Investigate the differences between fixed-point and floating-point number representations
USEFUL FOR

Electrical engineering students, computer science learners, and anyone interested in understanding floating-point arithmetic and binary conversions.

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

Similar threads

  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
4
Views
2K
Replies
9
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
Replies
2
Views
2K
Replies
10
Views
4K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 7 ·
Replies
7
Views
4K