Why is floating point byte swapping different from integer byte swapping?

Posted by CJ on Stack Overflow See other posts from Stack Overflow or by CJ
Published on 2010-04-28T06:36:09Z Indexed on 2010/04/28 6:43 UTC
Read the original article Hit count: 287

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about c++

Related posts about endianness