0

I am writing a program to implement this without using any built in function from C++. I am having some trouble figuring out how to find the decimal value and exponent for very small numbers like 0.25 0.15 0.0 etc. I need to convert my float to binary and then to hexadecimal because of my program spec.

From what I can understand to find out my exponent and decimal value for 32-bits hexadecimal, I convert the integer part of my float to binary, and its exponent is the number of digit - 1. Then my decimal value would be the offset 127 + the exponent. My decimal value in binary will be my exponent field and part of my 32 bits string.

This works only for large number, but for small numbers that requires negative exponent, I have no clue on how that works. Is there an easy systematic way that I can find this out?

Edited by red999: n/a

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Salem
1

http://www.psc.edu/general/software/packages/ieee/ieee.php
You subtract the offset from the exponent. A stored exponent of 128 say would map to a real exponent of 1. So fractions ultimately end up with negative real exponents (0.5 = 1 * 2^-1)

If you're able to extract the sign, exponent and mantissa bits, then the rest should be pretty easy. There is nothing irregular about fractions except for the magnitude of the exponent.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.