Re: XDR- External Data Representation [message #1202] |
Tue, 29 June 1993 07:39  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
gnaa38@aero.gla.ac.uk (Paul Porcelli) writes:
> Are there any facilities in Dos to convert a binary file to the XDR binary
> format.
> I am receiving binary data from a PC which i would then like to process on
> a Unix(Sun) Workstation using the IDL software.
> Any advice will be very welcome.
You could do the conversion in IDL on the Sun workstation. The binary
representation of numbers on the PC are the same as on the Sun, except that the
order of the bytes is reversed. You can use the BYTEORDER routine to convert
from PC format to Sun format. For example:
For byte arrays:
No conversion necessary.
For short integer arrays:
BYTEORDER, /SSWAP, array
For long integer, floating point, or complex arrays:
BYTEORDER, /LSWAP, array
For double precision arrays:
TEMP = LONG( array, 0, 2, N_ELEMENTS(array) )
BYTEORDER, TEMP, /LSWAP
TEMP = REVERSE(TEMP, 1)
array(0) = DOUBLE( TEMP, 0, N_ELEMENTS(array) )
That last one is kind of complicated, and is probably not as efficient as the
others, but I don't have any better ideas for how to handle double precision
numbers.
On the other hand, if you had IDL for Microsoft Windows, you could do the
conversion on the PC, either using the /XDR switch on the OPEN statement, or by
using BYTEORDER, /HTOXDR (host-to-XDR) and it's complement BYTEORDER, /XDRTOH.
Bill Thompson
P.S. By the way, the Sun workstation uses the same internal binary
representation as XDR.
|
|
|