Click to See Complete Forum and Search --> : Create floating point number from seperate bytes?


wadeee
April 16th, 2003, 01:44 AM
hello,
Ive run into a problem that I think there may be a good solution for.

My program is in C.

I have a single precision floating point value given to me in the following format:
3 seperate bytes
-------------------------------------
SFFFFFFF FFFFFFFF EEEEEEEE
thats 1 Sign bit, 15 Mantissa, 8 exponent.
(a different order than the IEEE standard)
Right now I just have the 3 bytes as unsigned char variables to hold these values. Now the question is, Is there an easy way to turn these 3 seperate bytes back into a floating point number?
I can manually shift them around but that seems way too hard.
Thanks in advance : )

Manish Malik
April 16th, 2003, 01:56 AM
The reverse of frexp() (http://www.cppreference.com/stdmath_details.html#frexp) is ldexp() (http://www.cppreference.com/stdmath_details.html#ldexp).

Manish Malik
April 16th, 2003, 02:28 AM
Also, for building the input numbers to the above functions, see http://www.codeguru.com/forum/showthread.php?s=&threadid=239980 .