locked
Converting Hex String to floating Number String based on S/390 Standart provided from IBM RRS feed

  • Question

  • Hi  @ all

    I need a solution for Single and double. This solution I need in VBA orVB for VSTO

    Below you can find a general discribtion.

                             Mantisse        Exponent

    Single                  24                    7

    Double                 56                    7

    Here I found a discribtion based on binary view:

    S = Sign, E = Exponent, M = Mantisse

    4.byte real

    SEEEEEEE MMMMMMMM MMMMMMMM MMMMMMMM

    8-Byte real

    SEEEEEEE MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM

    Thanks for Support

    Best Regards

    poorboy88

    
    • Moved by Cindy Meister MVP Tuesday, March 19, 2013 4:53 PM not VSTO or Office related
    Tuesday, March 19, 2013 10:38 AM

Answers

  • Hi There,

    First of all, in my opinion, if this string is Hex string, the double type in .net cannot meet your requirement, if it is a binary string, here is my suggestion:

    When you get this string, divide it into three part: the sign part only one bit, the exponent, 7 bit, and the left is the mantissa.

    For the exponent part, try

    Convert.ToInt32("010101", 2)

    to get the exponent.

    And then, you can follow this formula to get the whole value:

    http://en.wikipedia.org/wiki/Double-precision_floating-point_format  

    You need to modified it a little since you have 24 or 56 bit mantissa.

    I hope this will be helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Mike Feng Wednesday, April 3, 2013 4:32 PM
    Wednesday, March 20, 2013 3:11 PM

All replies

  • this question has nothing to do with VSTO technology at all, please try asking on general .net forum.
    Tuesday, March 19, 2013 11:28 AM
  • Hi There,

    First of all, in my opinion, if this string is Hex string, the double type in .net cannot meet your requirement, if it is a binary string, here is my suggestion:

    When you get this string, divide it into three part: the sign part only one bit, the exponent, 7 bit, and the left is the mantissa.

    For the exponent part, try

    Convert.ToInt32("010101", 2)

    to get the exponent.

    And then, you can follow this formula to get the whole value:

    http://en.wikipedia.org/wiki/Double-precision_floating-point_format  

    You need to modified it a little since you have 24 or 56 bit mantissa.

    I hope this will be helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Mike Feng Wednesday, April 3, 2013 4:32 PM
    Wednesday, March 20, 2013 3:11 PM