Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Unknown floating point representation

Reply
Thread Tools

Unknown floating point representation

 
 
sergei.s.mikhailov@gmail.com
Guest
Posts: n/a
 
      06-22-2006
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

 
Reply With Quote
 
 
 
 
Patricia Shanahan
Guest
Posts: n/a
 
      06-22-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
 
Patricia Shanahan
Guest
Posts: n/a
 
      06-22-2006
Patricia Shanahan wrote:
> (E-Mail Removed) 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;
}
}
}
 
Reply With Quote
 
Patricia Shanahan
Guest
Posts: n/a
 
      06-22-2006
Patricia Shanahan wrote:
> Patricia Shanahan wrote:
>> (E-Mail Removed) 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;
}
}
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Floating Point Representation (Question) Stefan Ram Java 2 12-26-2012 06:36 PM
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
Method to groom a string to floating point representation Alex DeCaria Ruby 15 04-14-2010 03:46 PM
Semi OT: Binary representation of floating point numbers Dilip C Programming 8 12-28-2006 06:36 AM
Binary representation of floating point numbers 63q2o4i02@sneakemail.com Python 10 12-15-2005 03:45 PM



Advertisments