I recently had to convert one swim to another. It appears that the XDR format uses an odd format for its floats. Therefore, when converting from XDR to standard floats, this code did this.
#include <rpc/rpc.h> // Read in XDR float array, copy to standard float array // out array needs to be allocated before the function call bool convertFromXdrFloatArray(float *in, float *out, long size) { XDR xdrs; xdrmem_create(&xdrs,(char *)in, size*sizeof(float), XDR_DECODE); for(int i = 0; i < size; i++) { if(!xdr_float(&xdrs, out++)) { fprintf(stderr,"%s:%d:ERROR:xdr_float\n",__FILE__,__LINE__); exit(1); } } xdr_destroy(&xdrs); return true; }
source share