Why is floating point byte swapping different from integer byte swapping?
- by CJ
I have a binary file of doubles that I need to load using C++. However, my problem is that it was written in big-endian format but the fstream operator will then read the number wrong because my machine is little-endian. It seems like a simple problem to resolve for integers, but for doubles and floats the solutions I have found won't work. How can I (or should I) fix this?
I read this as a reference for integer byte swapping:
http://stackoverflow.com/questions/105252/how-do-i-convert-between-big-endian-and-little-endian-values-in-c