[fpc-pascal] Converting big-endian signed 16bits values to fpc integer
Jeppe Græsdal Johansen
jjohan07 at student.aau.dk
Mon Apr 16 00:41:59 CEST 2012
Just use the BEtoN function. That will convert whatever big-endian
number to your native endian.
I don't know what speed it has, but it sure is elegant :)
Den 16-04-2012 00:38, Giuliano Colla skrev:
> I'm dealing with a large number of data coming from an external device.
> They are big-endian 16 bits signed numbers, which must be converted to
> integer and to real to perform calculations.
>
> Besides the obvious solutions of treating them as isolated bytes,
> multipying by 256 the highest, adding the lower, and oring wit
> $FFFF0000, or whatever sizeof(Integer) suggests if the result is
> bigger than 32767, is there a more efficient and elegant way to
> achieve the result?
>
> I'm a bit lost on all available data types, and unable to tell apart
> the ones which are platform specific and the ones which are not, which
> assignments give the proper result and which do not.
>
> Any suggestion would be greatly appreciated.
>
> Giuliano Colla
>
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list