Results 1 to 3 of 3

Thread: Number conversion

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2001
    Posts
    1

    Thumbs up Number conversion

    I am trying to convert a decimal number to an IEEE 754 standard floating point number. I am using the formula -1*s *1.m*2^e-127 where s is the sign bit, m is the mantissa and e is the exponent, but I can't get it to give the correct results. Are there any VB add ons available I can use to do this? I know Java has floating point functions built in but I don't know if I can access these from VB?? Any ideas?

  2. #2
    Member
    Join Date
    Sep 1999
    Location
    Zurich, Switzerland
    Posts
    55
    Used "double" data type?

  3. #3
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151

    Some information.

    http://www.research.microsoft.com/~h...ieeefloat.html

    The above site has the technical specifications for floating point numbers, but it is a confusing issue. The official specifications do not mirror the way data is stored in PC memory, which might not be the same for all CPU types. The following refers to 86x or Intel like systems.

    Due to normalization, the mantissa of a non zero number always has a leading one bit. The CPU generates this bit as required for arithmetic purposes, but does not store it in memory. This can cause confusion if you try to analyze data in memory.

    Two and four byte variables are stored in memory in a non intuitive fashion, which can be confusing. Following is an example showing what happens in memory.

    Decimal 125,456,987 is Hex 077A 525B, but is stored in memory as 5B52 7A07 (Long variable).

    Single & double variables are similarly stored in a non intuitive fashion.

    While there are other ways to analyze how data is stored in memory, I did it by writing some data to a file and then using a Hex Editor to investigate the data.
    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

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