CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2002
    Posts
    24

    Create floating point number from seperate bytes?

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

  2. #2
    Join Date
    Feb 2001
    Location
    teh INTARWEB
    Posts
    542
    The reverse of frexp() is ldexp().

  3. #3
    Join Date
    Feb 2001
    Location
    teh INTARWEB
    Posts
    542
    Also, for building the input numbers to the above functions, see http://www.codeguru.com/forum/showth...hreadid=239980 .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured