Was looking for a way to IEEE floating point numbers to IBM floating point format for a old system we are using.
Is there a general formula we can use in C# to this
I recently had to convert one float to another. It looks like XDR format uses an odd format for its floats. So when converting from XDR to standard floats, this code did it.
#include
// 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;
}