I have this binary number 11000000110011000001011001111101 which should have this decimal representation 0.0736327171325684.
Is there a smart way to figure out how to interpret the binary value as the given decimal value?
Some background
I have a binary file which contain REAL*4 datatype from fortran (I believe fortfran 77).
I found this from the fortran language reference:
A REAL element has a sign bit, an 8-bit exponent, and a 23-bit fraction. These REAL elements in f77 conform to the IEEE standard.
Though, trying to apply the IEEE standard i get this decimal value -6.37774515152, which is incorrect. I've been experimenting with big/little-endian and 64-bit. I also tried every offset in my binary data to make sure I wasn't looking at the wrong place, but no luck (closest I could get was still 0.011872760951519054 of, which I believe would be much larger than a precision error).
UPDATE: I'm sorry if this was unclear: I don't have the original fortran code that generated the binary file.
Some extra information that might be helpful:
- The code is about 20 years old.
- From code in the same project I found mentions of conversion between IEEE and microsoft binary format.
- I also found mentions of REAL*4 which should be an alias for REAL according to the language reference.
- I have successfully decoded the type INTEGER and INTEGER2 from the same file. The INTEGER type is an 8-bit integer. The INTEGER2 type is an 16-bit integer with little endianness. Could this be a hint that the REAL*4 is also little endian?
- As pointed out in the comments the reference linked above is to a compiler for fortran, and we can't be sure that the code that generated the binary used the same compiler. Therefore it's possible that the REAL*4 type isn't using the IEEE standard at all.