CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 1999
    Location
    Finland,Vaasa
    Posts
    7

    How to convert 4 byte binary to single???

    I'm stuck...
    How do I convert binary to Single (Short real IEEE 32bit)
    ,01000001,11011001,01011011,00000011


    Does anybody know if VB's single are the same as short real??? If not what does the bits represent?

    Best Regars/ Toby


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: How to convert 4 byte binary to single???

    wanna try this one?

    Function conv(byval strVal as string) as Single
    Dim i as Integer
    Dim j as Integer
    Dim r as Single
    for i = len(strVal) to 1 step -1
    r = r + CInt(mid(strVal, i, 1)) * 2 ^ j
    j = j + 1
    next i
    conv = r
    End Function



    to use it:
    dim s as single
    s = conv("your bytes goe here")
    e.g.
    s = conv("00101111")


  3. #3
    Join Date
    Jul 1999
    Location
    Finland,Vaasa
    Posts
    7

    Re: How to convert 4 byte binary to single???

    Thanks for the tip,

    But your code does not consider the mattisa and + or – sign. So the question remains, how is the Single built?
    I’ve thing it is like this, but then the values are totally wrong

    (+/-) eeeeeee
    esssssss
    ssssssss
    ssssssss

    Is it like that?! And how do I i convert it?

    Best Regards Toby



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