The answer for C ++ is here: How to check if the C ++ compiler uses the IEEE 754 floating point standard
For C, Appendix F of the current C standard states that the preprocessor constant __STDC_IEC_559__ will be predefined with a value of 1 if the platform complies with the IEEE 754 specification for floating point arithmetic. But older C compilers cannot predefine it, even if the float is indeed IEEE 754.
However, this is not enough for any language: this correspondence only guarantees the semantics of IEEE 754, not the binary representation, and since you are dumping the binary representation into a file, you will also need to handle the content problem. This becomes even more complicated since propositions for integers may differ from continents for floats.
In the end, it is much better to use a textual representation for storing floating point values if you want to achieve portability between different platforms, present and future. Of course, you will need to use maximum precision for this view.
Another solution is provided by http://hdfgroup.org , which effectively handles this problem for large amounts of data.
source share