I'm trying to reverse engineer some old file format (Cinema4D old version), for which I cannot find the specification.
In this file format, I've managed to find that float values are stored as four bytes, but they don't seem to be normal IEEE format, this is not an endian issue. I've spent a lot of time lately with hex<->float conversion tools to figure this out.
Here are some sample values:
0 = 00 00 00 00
1 = 80 00 00 41
2 = 80 00 00 42
4 = 80 00 00 43
8 = 80 00 00 44
0.25 = 80 00 00 3F
16384 = 80 00 00 4F
My observation from two lines above is that something seems to wrap around here, when going from 3F to 4F
1.5 = C0 00 00 41
2.5 = A0 00 00 42
-1 = 80 00 00 C1
-1.5 = C0 00 00 C1
-2 = 80 00 00 C2
-3 = C0 00 00 C2
So, here are some observations:
- Increasing the last byte +1, doubles the value
- If the high bit of the last byte is set, the number is negative
- The first byte does something with non-integer values
Although there are some obvious patterns, and there's some exponent/mantissa going on, I haven't been able to figure this out. Maybe I'm even missing something obvious and it's normal IEEE ? Figuring out how many bits for mantissa/exponent etc isn't the problem (in the examples above, two middle bytes are zero), first I need to figure out the formula to get to the floating point value