What type is this 6 byte (48 bit) number... floating point? integer?
This looks like 6 byte[48 bit] real float point pascal format
A Pascal real has a value between 2.9E-39 (2.9 x 10^-39) to 1.7E38 (1.7 x 10^38).
if this is the case you could convert from the hex number to double with this method.
C# Code
[I took it from wiki listed bellow at article end but anyway: Turbo Pascal Real]
// This program expects a byte array named real48[6] to be loaded with the 6 bytes of the real from the file.
Double exponentbase = 129d;
Double exponent = real48[0] - exponentbase; // The exponent is offset so deduct the base.
// Now Calculate the mantissa
Double mantissa = 0.0;
Double value = 1.0;
// For Each Byte.
for (int i = 5; i >= 1; i--)
{
int startbit = 7;
if (i == 5)
{ startbit = 6; } //skip the sign bit.
//For Each Bit
for (int j = startbit; j >= 0; j--)
{
value = value / 2;// Each bit is worth half the next bit but we're going backwards.
if (((real48[i] >> j) & 1) == 1) //if this bit is set.
{
mantissa += value; // add the value.
}
}
}
if (mantissa == 1.0 && real48[0] == 0) // Test for null value
return 0.0;
if ((real48[5] & 0x80) == 1) // Sign bit check
mantissa = -mantissa;
return (1 + mantissa) * Math.Pow(2.0, exponent);
If you want a more modern | POO code to achieve that you could use the code Simeon Pilgrim show us in this article :
Pascal 6-byte real to IEEE 8-byte double
Warning To use the method exposed by Pilgrim you need to be careful with byte ordering
// expl: 100=> 87 00 00 00 00 48 var theMethodParam = new ushort[] { 0x0087, 0x0000, 0x4800 };
You can get more info about this topic here:
Turbo Pascal Real