byte swapping 32-bit float and weird od results

I'm attempting to read a file that is composed of complex 32-bit floating point values on Solaris 10 that came from a 64-bit Red Hat computer.

When I first tried reading the file, it looked like there was a byte-swapping problem and after running the od command on the file Solaris and Red Hat computers, I saw that they were indeed swapped (every other byte). So, I wrote a little Java program that would swap every other byte and the result was the at the byte-level, the files were the same on both computers. The following is the result of running 'od -x' on the file, showing the first 32-bits which represent the real portion of the first complex number:

f8a6 be03 cd76 bc99

What's weird is that when I run 'od -f' on both computers to see the 32-bit floating point value, I get different results! On the Red Hat computer I get: -1.288782e-01 and on the Solaris computer I get: -2.7055474e+34 :confused:. How can I have the same byte level file yet come up with completely different values when I try to print out the bytes as 32-bit floats?

This is really messing me up trying to write a C++ program to read this file on the Solaris computer. I'm getting the same value in my C++ code as what I see when I run 'od -f' on the Solaris computer. I've tried just about everything that I can think of and haven't been able to get past this.

Does anyone have any idea on what's going on with the od command between the Red Hat and Solaris computers? Any ideas on how to get my C++ code to give me the correct value for the 32-bit float?

On the 64-bit platform, what format are the floating point numbers? Double precision (64-bit) IEEE 754 binary floating-point numbers? Single precision (32-bit) binary IEEE 754 floating-point numbers? Are they in standard IEEE 754 interchange format or some form of custom arithmetic format? Binary or decimal format?

In other words, first you need to figure out exactly what format was used to represent the floating points numbers.

If you provide more information we can probably help you.

I never did figure out the od problem, but I was able to get the bytes swapped properly and everything is working good.