1

I'm trying to decode this Firebird blob to extract decimal numbers from it (not sure exactly what format they'll be in). Some context is the blob is storing vibration spectrum data charting amplitude against frequency. I'm pretty sure that the blob only contains the amplitude data though. Here's an example blob export for a small test spectra i generated:

0000803F0000004000004040000080400000A0400000C0400000E0400000004100001041000020410000304100004041000050410000604100007041000080410000884100009041000098410000A0410000A8410000B0410000B8410000C0410000C8410000D0410000D8410000E0410000E8410000F0410000F84100000042000004420000084200000C4200001042000014420000184200001C4200002042000000006666663FA4707D3F77BE7F3F72F97F3F58FF7F3F0000803F0000C03F0000004000002040000040400000604000008040000088400000904000009840CDCC9C400000A0400000C84200007A4400401C46

As far as i can tell, it looks like each number is represented by 4 bytes of data which is hexadecimal in this export. I know it's 4 bytes per value because of how it lines up with my test set below. I also think that potentially the first 2 bytes are the fractional part, and the last 2 being the whole numbers? I think it might use a scaling factor as well. Here is my test set (same as above, just reformatted), with the actual values (amplitudes):

Actual Value    Blob Section
1   0000803F
2   00000040
3   00004040
4   00008040
5   0000A040
6   0000C040
7   0000E040
8   00000041
9   00001041
10  00002041
11  00003041
12  00004041
13  00005041
14  00006041
15  00007041
16  00008041
17  00008841
18  00009041
19  00009841
20  0000A041
21  0000A841
22  0000B041
23  0000B841
24  0000C041
25  0000C841
26  0000D041
27  0000D841
28  0000E041
29  0000E841
30  0000F041
31  0000F841
32  00000042
33  00000442
34  00000842
35  00000C42
36  00001042
37  00001442
38  00001842
39  00001C42
40  00002042
0   00000000
0.9 6666663F
0.99    A4707D3F
0.999   77BE7F3F
0.9999  72F97F3F
0.99999 58FF7F3F
1   0000803F
1.5 0000C03F
2   00000040
2.5 00002040
3   00004040
3.5 00006040
4   00008040
4.25    00008840
4.5 00009040
4.75    00009840
4.9 CDCC9C40
5   0000A040
100 0000C842
1000    00007A44
10000   00401C46

Its pretty obvious that its not just a straight hexadecimal - decimal conversion, but i feel like this is something an expert would be able to recognize. Any help or pointers on how to decode this 4 bytes of hex back to a number value would be much appreciated!

Rory LM
  • 160
  • 2
  • 15

1 Answers1

3

That is industry-standard 4-bytes floating point format (single float).

Of course, bytes order should be accounted for too (you see it visually reversed in your dump above, comparing to normal writing of hexadecimal integer numbers on the site above).

Arioch 'The
  • 15,799
  • 35
  • 62
  • 1
    I think the endianness was the crucial part i was missing, and with the help of the Wikipedia article's "Converting from single-precision binary to decimal", I've managed to decode the blob. Thank you! – Rory LM Nov 19 '19 at 06:50
  • I don't think you had to think about endianess, frankly. Unless you was extracting all that data manually @RoryLM Depending on the language you use and on the hardware processor, it was either a matter of taking a `pointer` to `short float` or `single` data type, setting it at the start of raw BLOB data and then iterating it, or allocating `single` variable and copying BLOB's 4 bytes chunks into it, then reading it, in the loop. I guess non-Intel endianess became marginal rarity today. – Arioch 'The Nov 19 '19 at 10:35