Use C#
BitConverter[
^] class.
E.g.
static void Main(string[] args)
{
{
byte[] b = { 0x00, 0x00, 0x00, 0xE0, 0x97, 0xA5, 0x61, 0x40, };
double d = BitConverter.ToDouble(b, 0);
Console.WriteLine("from file: {0,-20} = {1}", d, b.Aggregate("", (s, x) => s += " 0x" + x.ToString("X02")));
}
{
double d = 103.15;
byte[] b = BitConverter.GetBytes(d);
Console.WriteLine("double: {0,-20} = {1}", d, b.Aggregate("", (s, x) => s += " 0x" + x.ToString("X02")));
}
{
float d = 103.15f;
byte[] b = BitConverter.GetBytes(d);
Console.WriteLine("float: {0,-20} = {1}", d, b.Aggregate("", (s, x) => s += " 0x" + x.ToString("X02")));
}
}
The result of the above is:
from file: 141.174789428711 = 0x00 0x00 0x00 0xE0 0x97 0xA5 0x61 0x40
double: 103.15 = 0x9A 0x99 0x99 0x99 0x99 0xC9 0x59 0x40
float: 103.15 = 0xCD 0x4C 0xCE 0x42
Please note: none of the patterns match your description:
- The 1st entry converts the first bytes into a
double
: 141.17... (not 103.15 as you claim this would be).
- The other two entries convert 103.15 as
double
and
float
respectively into bytes... (not as expected).
It seems that either your claim for 103.15 is wrong, or the stored data is not a standard conformat floating point number or ...?
Cheers
Andi