Thread: Fwd: How to tell the endianness of a sac file

Started: 2008-09-06 08:49:45
Last activity: 2008-09-06 08:49:45
Topics: SAC Help
Kuang He
2008-09-06 08:49:45
Ying Cal
There is currently no easy way to check the endianness of a sac file
directly, but

What you can do is something like
% od -j 304 -N 4 -t d4 sacfile
0000460 6

% od -j 304 -N 4 -t d4 sacfile.swap
0000460 100663296

It outputs the header version number, which should be 6. If it is
not 6 (100663296 or anything else)
then you either have a byte swapped sac file or the file is not a
sacfile. This will only tell you if
the file you are looking at is the same endianness as your system.

Together with the little program below (which was take from the C
FAQ), we are able to tell the endianness of the sac file! :-)

* Determine whether an Operating System is big-endian or little endian

#include <stdio.h>

int main()
int x = 1;

printf("This computer is ");
if(*(char *)&x == 1)

return 0;

Best regards,

Kuang He
Department of Physics
University of Connecticut
Storrs, CT 06269-3046

Tel: +1.860.486.4919

The current version of SAC (v101.1) can read and write both types of
sac files.


Page built 20:34:47 | v.b'59d0d2