Unknown floating point representation

Discussion in 'Java' started by sergei.s.mikhailov@gmail.com, Jun 22, 2006.

  1. Guest

    I am trying to determine what floating point number representation is
    used by BMC Patrol agents (proprietary enterprise management system). I
    know what the float value should be and I see the bits as they are
    coming through the wire, I just can't figure out what representation is
    used. It does not look like IEEE 754. Below are some example, of the
    bits I see on the wire in Hex and Binary, and what I know the final
    float should be.

    HEX:830d4000 BIN:10000011000011010100000000000000 Should be: -2
    HEX:838f7500 BIN:10000011100011110111010100000000 Should be: -2.3333
    HEX:8493e000 BIN:10000100100100111110000000000000 Should be: -3
    HEX:8a2c2a81 BIN:10001010001011000010101010000001 Should be -.66666

    Untimately, I am looking for an algorithm that would decode the floats.
    It looks like the sign bit is the msb, beyong that I am lost.

    Thanks,
    Sergei
    , Jun 22, 2006
    #1
    1. Advertising

  2. wrote:
    > I am trying to determine what floating point number representation is
    > used by BMC Patrol agents (proprietary enterprise management system). I
    > know what the float value should be and I see the bits as they are
    > coming through the wire, I just can't figure out what representation is
    > used. It does not look like IEEE 754. Below are some example, of the
    > bits I see on the wire in Hex and Binary, and what I know the final
    > float should be.
    >
    > HEX:830d4000 BIN:10000011000011010100000000000000 Should be: -2
    > HEX:838f7500 BIN:10000011100011110111010100000000 Should be: -2.3333
    > HEX:8493e000 BIN:10000100100100111110000000000000 Should be: -3
    > HEX:8a2c2a81 BIN:10001010001011000010101010000001 Should be -.66666
    >
    > Untimately, I am looking for an algorithm that would decode the floats.
    > It looks like the sign bit is the msb, beyong that I am lost.
    >
    > Thanks,
    > Sergei
    >


    I don't recognize the format, but I think I've cracked it. It seems to
    use a decimal point, but with binary representation of the mantissa.
    Also, the exponent is at the LSB end of the number, after the mantissa
    sign and mantissa.

    Numbering bits with MSB as bit 31, LSB as bit 0:

    Bit 31: Mantissa sign bit (negative in all cases)

    Bits 30? through 8 Mantissa.

    Bit 7: Direction to shift the decimal point. On means move the point to
    the left (divide by a positive power of 10).

    Bits 6 through 0: Number of places to shift the decimal point. 0 means
    there are 5 decimal digits after the decimal point, 81 in bits 7 through
    0 means 6 decimal digits after the decimal point.

    Thanks for a nice little puzzle.

    Patricia
    Patricia Shanahan, Jun 22, 2006
    #2
    1. Advertising

  3. Patricia Shanahan wrote:
    > wrote:
    >> I am trying to determine what floating point number representation is
    >> used by BMC Patrol agents (proprietary enterprise management system). I
    >> know what the float value should be and I see the bits as they are
    >> coming through the wire, I just can't figure out what representation is
    >> used. It does not look like IEEE 754. Below are some example, of the
    >> bits I see on the wire in Hex and Binary, and what I know the final
    >> float should be.
    >>
    >> HEX:830d4000 BIN:10000011000011010100000000000000 Should be: -2
    >> HEX:838f7500 BIN:10000011100011110111010100000000 Should be: -2.3333
    >> HEX:8493e000 BIN:10000100100100111110000000000000 Should be: -3
    >> HEX:8a2c2a81 BIN:10001010001011000010101010000001 Should be -.66666
    >>
    >> Untimately, I am looking for an algorithm that would decode the floats.
    >> It looks like the sign bit is the msb, beyong that I am lost.
    >>
    >> Thanks,
    >> Sergei
    >>

    >
    > I don't recognize the format, but I think I've cracked it. It seems to
    > use a decimal point, but with binary representation of the mantissa.
    > Also, the exponent is at the LSB end of the number, after the mantissa
    > sign and mantissa.
    >
    > Numbering bits with MSB as bit 31, LSB as bit 0:
    >
    > Bit 31: Mantissa sign bit (negative in all cases)
    >
    > Bits 30? through 8 Mantissa.
    >
    > Bit 7: Direction to shift the decimal point. On means move the point to
    > the left (divide by a positive power of 10).
    >
    > Bits 6 through 0: Number of places to shift the decimal point. 0 means
    > there are 5 decimal digits after the decimal point, 81 in bits 7 through
    > 0 means 6 decimal digits after the decimal point.
    >
    > Thanks for a nice little puzzle.
    >
    > Patricia


    Here is a converter, based on this theory. Use at your own risk. I'm not
    sure there is really enough data about how the exponent works.

    public class WeirdFloat {

    /*
    HEX:830d4000 BIN:10000011000011010100000000000000 Should be: -2
    HEX:838f7500 BIN:10000011100011110111010100000000 Should be: -2.3333
    HEX:8493e000 BIN:10000100100100111110000000000000 Should be: -3
    HEX:8a2c2a81 BIN:10001010001011000010101010000001 Should be -.66666
    */
    public static void main(String[] args) {
    long[] inputs = {0x830d4000L, 0x838f7500L, 0x8493e000L, 0x8a2c2a81L};
    for(long in: inputs){
    System.out.printf("%xl %f\n",in,toDouble(in));
    }
    }
    static double toDouble(long in){
    long signBit = 0x80000000L;
    long mantissaBits = 0x4fffffffL;
    long expSignBit = 0x80L;
    long expBits = 0x4fL;

    boolean isNegative = (in & signBit)==signBit;
    double result = (in & mantissaBits)>>8;
    boolean negativeExponent = (in & expSignBit)==expSignBit;
    int exponent = (int)(in & expBits);
    if(negativeExponent){
    exponent = -exponent;
    }
    exponent -= 5;
    result *= Math.pow(10,exponent);
    if(isNegative){
    return -result;
    }else{
    return result;
    }
    }
    }
    Patricia Shanahan, Jun 22, 2006
    #3
  4. Patricia Shanahan wrote:
    > Patricia Shanahan wrote:
    >> wrote:
    >>> I am trying to determine what floating point number representation is
    >>> used by BMC Patrol agents (proprietary enterprise management system). I
    >>> know what the float value should be and I see the bits as they are
    >>> coming through the wire, I just can't figure out what representation is
    >>> used. It does not look like IEEE 754. Below are some example, of the
    >>> bits I see on the wire in Hex and Binary, and what I know the final
    >>> float should be.
    >>>
    >>> HEX:830d4000 BIN:10000011000011010100000000000000 Should be: -2
    >>> HEX:838f7500 BIN:10000011100011110111010100000000 Should be: -2.3333
    >>> HEX:8493e000 BIN:10000100100100111110000000000000 Should be: -3
    >>> HEX:8a2c2a81 BIN:10001010001011000010101010000001 Should be -.66666
    >>>
    >>> Untimately, I am looking for an algorithm that would decode the floats.
    >>> It looks like the sign bit is the msb, beyong that I am lost.
    >>>
    >>> Thanks,
    >>> Sergei
    >>>

    >>
    >> I don't recognize the format, but I think I've cracked it. It seems to
    >> use a decimal point, but with binary representation of the mantissa.
    >> Also, the exponent is at the LSB end of the number, after the mantissa
    >> sign and mantissa.
    >>
    >> Numbering bits with MSB as bit 31, LSB as bit 0:
    >>
    >> Bit 31: Mantissa sign bit (negative in all cases)
    >>
    >> Bits 30? through 8 Mantissa.
    >>
    >> Bit 7: Direction to shift the decimal point. On means move the point to
    >> the left (divide by a positive power of 10).
    >>
    >> Bits 6 through 0: Number of places to shift the decimal point. 0 means
    >> there are 5 decimal digits after the decimal point, 81 in bits 7 through
    >> 0 means 6 decimal digits after the decimal point.
    >>
    >> Thanks for a nice little puzzle.
    >>
    >> Patricia

    >
    > Here is a converter, based on this theory. Use at your own risk. I'm not
    > sure there is really enough data about how the exponent works.

    ....

    I found a couple of typos, that don't affect the results on the limited
    data:


    public class WeirdFloat {

    /*
    HEX:830d4000 BIN:10000011000011010100000000000000 Should be: -2
    HEX:838f7500 BIN:10000011100011110111010100000000 Should be: -2.3333
    HEX:8493e000 BIN:10000100100100111110000000000000 Should be: -3
    HEX:8a2c2a81 BIN:10001010001011000010101010000001 Should be -.66666
    */
    public static void main(String[] args) {
    long[] inputs = {0x830d4000L, 0x838f7500L, 0x8493e000L, 0x8a2c2a81L};
    for(long in: inputs){
    System.out.printf("%xl %f\n",in,toDouble(in));
    }
    }
    static double toDouble(long in){
    long signBit = 0x80000000L;
    long mantissaBits = 0x7fffff00L;
    long expSignBit = 0x80L;
    long expBits = 0x7fL;

    boolean isNegative = (in & signBit)==signBit;
    double result = (in & mantissaBits)>>8;
    boolean negativeExponent = (in & expSignBit)==expSignBit;
    int exponent = (int)(in & expBits);
    if(negativeExponent){
    exponent = -exponent;
    }
    exponent -= 5;
    result *= Math.pow(10,exponent);
    if(isNegative){
    return -result;
    }else{
    return result;
    }
    }
    }
    Patricia Shanahan, Jun 23, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    10
    Views:
    2,829
    Torsten Bronger
    Dec 15, 2005
  2. Dilip
    Replies:
    8
    Views:
    469
    Ernie Wright
    Dec 28, 2006
  3. Saraswati lakki
    Replies:
    0
    Views:
    1,322
    Saraswati lakki
    Jan 6, 2012
  4. Alex DeCaria
    Replies:
    15
    Views:
    205
    Josh Cheek
    Apr 14, 2010
  5. Stefan Ram
    Replies:
    2
    Views:
    245
    Eric Sosman
    Dec 26, 2012
Loading...

Share This Page