Unknown floating point representation

S

sergei.s.mikhailov

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
 
P

Patricia Shanahan

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
 
P

Patricia Shanahan

Patricia said:
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;
}
}
}
 
P

Patricia Shanahan

Patricia said:
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;
}
}
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top