CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 1999
    Posts
    25

    How to: convert float to DWORD etc.

    Hi,

    Is there anyone who has a C++ - class with conversionmethods like:

    - convert float to DWORD and reverse
    - convert float to a high and a low word and reverse
    - convert double to two DWORD's and reverse
    - convert double to four words and reverse
    - convert dezimal to hex and reverse
    - convert dezimal to octal and reverse
    - convert dezimal to bitstring and reverse

    or is there a class like this on the web ?


    Thanks for your answers.


    Regards,

    Daniel



  2. #2
    Join Date
    May 1999
    Posts
    2

    Re: How to: convert float to DWORD etc.

    Hi,
    I have no such a class, but it is pretty easy to write your own. If you need help for this, write me.
    (Sorry for my bad Endglish!)


  3. #3
    Join Date
    May 1999
    Posts
    25

    Re: How to: convert float to DWORD etc.

    Hi iliani,

    I only know, that the conversion from float to bitstream (or high and low word)
    has a norm at IEEE. Could you explain, how you would write a method to
    convert float to high and low words ?
    And the same from double to four words ?

    Thanks for your help.

    Regards,
    Daniel



  4. #4
    Join Date
    May 1999
    Posts
    25

    Re: How to: convert float to DWORD etc.

    I only know that the bitstream is organized in:

    for float single format:
    --------------------------------------------------------
    <s> <exponent> <significand>
    ¦ ¦ ¦
    1 bit 8 bit 23 bit = 32 bit (DWORD)

    And the formula is: X = (-1)^s * 2^(exponent - 127) * (1.significand)

    s = sign bit = bit string of length one.
    exponent = biased exponent = bit string of length 8.
    significand = bit string of length 23 encoding the number's
    significant bits that follow the binary point,
    yielding a 24 bit significand digit field
    for the number that always begins "1.____".


    for double format:
    --------------------------------------------------------
    <s> <exponent> <significand>
    ¦ ¦ ¦
    1 bit 11 bit 52 bit = 64 bit (HIGH DWORD + LOW DWORD)

    And the formula is: X = (-1)^s * 2^(exponent - 1023) * (1.significand)

    s = sign bit = bit string of length one.
    exponent = biased exponent = bit string of length 11.
    significand = bit string of length 52 encoding the number's
    significant bits that follow the binary point,
    yielding a 53 bit significand digit field
    for the number that always begins "1.____".



    I only have an interface of word and I has to transfer the resulting
    DWORD's with shift operations to high and low words.


    Thanks for your interest and help.

    Regards,

    Daniel



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