>> I am trying to determine what floating point number representation is
>> used by BMC Patrol agents (proprietary enterprise management system). I
[quoted text clipped - 36 lines]
>
> 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 - 23 Jun 2006 00:54 GMT
>>> I am trying to determine what floating point number representation is
>>> used by BMC Patrol agents (proprietary enterprise management system). I
[quoted text clipped - 39 lines]
> 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;
}
}
}