1

I have a a binary file format with a bunch of headers and floating point data, worthy to note this fileformat uses big-endian. The structure looks like this:

Header [240 byte]
Data [x byte]
Header [240 byte]
Data [x byte]

and so on...

Parsing the headers works fine, I get the correct output for every file. The problem is with the "Data" The documentation says it is in 4-byte IBM floating-point. As far as I know the C++ float structure uses the IEEE standard so probably my problem is the conversion.

I sholud find some way to convert the IBM floating-point to IEEE floating point.

Question: Is it possible? How/Where should I start, if I have very poor knowledge with these basic structures?

timko.mate
  • 364
  • 1
  • 3
  • 13
  • 1
    You can convert but of course not losslessly: https://en.wikipedia.org/wiki/IBM_hexadecimal_floating_point – Dan M. Feb 18 '19 at 13:06
  • Yes. I've read it, just dont know how to implement it. Probably I need a _tool_, but cant really find. Asked because maybe I am in a wrong path. – timko.mate Feb 18 '19 at 13:10
  • @dewaffled Thank you! I will take a look. – timko.mate Feb 18 '19 at 13:11
  • 2
    `As far as I know the C++ float structure uses the IEEE standard` that's not correct. The C++ standard doesn't require the use of IEEE-754. It simply defines the necessary limits. [Does the C++ standard specify anything on the representation of floating point numbers?](https://stackoverflow.com/q/34294938/995714), [Are IEEE float and double guaranteed to be the same size on any OS?](https://stackoverflow.com/q/24157094/995714), [Do any real-world CPUs not use IEEE 754?](https://stackoverflow.com/q/2234468/995714) – phuclv Feb 18 '19 at 15:09
  • 1
    [Reading IBM floating-point in C++](https://stackoverflow.com/q/54737840/995714) – phuclv Feb 18 '19 at 15:09
  • Sounds suspiciously like a SEG-Y file. If it is, you should be able to find a bunch of existing readers for that file format. – Mark Dickinson Feb 18 '19 at 20:08
  • It is. I am just curious. Turned out it is a good practice! :) – timko.mate Feb 18 '19 at 20:32

0 Answers0