Page 2 of 2 First 12
  • Jump to page:
    #16
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    254
    Rep Power
    13
    WOW, ya I read that and it explains stuff
    Your code turns the bytes into single, i suppose it does it correctly, but single is different from long or float32? Because i tested it with the bytes I recieve from the query and it over flows for most of them.....

    A float in C++ is typically: composed of 32 bits (4 bytes) comprised of:
    1. A sign bit.
    2. 8 bit exponent (bias of 127)
    3. 23 bit mantissa
    for example:
    1. 167
    2. 85
    3. 23
    4. 68

    turns into 1.763713E-15 (with your function)

    and over flows with

    1. 152
    2. 109
    3. 231
    4. 67
    Thank you for any help.
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Dublin
    Posts
    413
    Rep Power
    14
    You need don't need to know which format vb uses - just what is used by your wisock source.

    A good way to find out is to see how 0.5, 0.25, 0.125 or similar are represented. I guess the two questions are whether the eponent comes before or after the mantissa and whether the leading 1 bit of the mantissa is implied or included.

    If you can see what four-byte arrays you get for the above numbers then you can build from there.

    I'e edited the above function, by the way ... I made a mistake with the sign bit.


    ... one more thing ... the overflow error is from the bytes(2) * 256 line in function. The temporary calculation is being done on the integer range - which the result is too big for. So change to bytes(2) * 256& to force long integer calculation.
    Last edited by epl; March 21st, 2003 at 05:12 AM.
  4. #18
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    254
    Rep Power
    13
    Or just use microsoft's solution, or at least thats what they say, http://support.microsoft.com/default...;en-us;q171652

    hmmmm......?
    Thank you for any help.
  6. #19
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Dublin
    Posts
    413
    Rep Power
    14
    if the information going into the byte array is in the format you need, there's no need to use the byte array at all - just read into a user defined type or a single.
  8. #20
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    254
    Rep Power
    13
    well thats the problems, it gives an error when I try the Type it gives error: "only user-defined types defined in public object modules can be coerced to or from a variant or passed to late-bound functions". I define the type in module and in the form...
    then when I try reading into long, or even into a string just part of a packet like 5 bytes of it, it give an error: "datagram is too large to fit into the buffer and is trucated"
    Thank you for any help.
  10. #21
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Dublin
    Posts
    413
    Rep Power
    14
    What do LenB(TypeName) and LenB(VariableName) give?
  12. #22
  13. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    254
    Rep Power
    13
    hmm, it gives their size? 8 for type and 4 for variable?
    Thank you for any help.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo