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@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to