[fpc-pascal] Converting big-endian signed 16bits values to fpc integer

Giuliano Colla giuliano.colla at fastwebnet.it
Mon Apr 16 00:38:28 CEST 2012


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






More information about the fpc-pascal mailing list