[R] reading short int and float from binary connection
Jim Lemon
bitwrit at ozemail.com.au
Thu Mar 18 11:31:03 CET 2004
Angel Lopez wrote:
> Thanks for the advise.
> I think I've found the solution, the problem was that the file had been
> written from a C program using a structure containing floats and int, if
> I rewrite the C code not using a structure but independent floats and
> ints the data then is read smoothly into R. I still can't figure out why
> a structure is different or how should I have read it into R but it is
> probably more a C than an R question .
>
You're probably right there. A C structure may be silently aligned by the
compiler so that value fields are not contiguous in memory. A binary write of
such a structure cannot be assumed to have bytes in the same order described
in the structure definition.
Jim
More information about the R-help
mailing list