Hi all
Does anyone know how to return the lest significant byte of a given number? e.g. function least_significant_byteof (num: integer): byte;
An algorithm in Pascal or C would be fine.
Thanks,
On 02 Sep 2009, at 20:16, Prof A Olowofoyeku (The African Chief) wrote:
Does anyone know how to return the lest significant byte of a given number? e.g. functionleast_significant_byteof (num: integer): byte;
An algorithm in Pascal or C would be fine.
least_significant_byteof:=num and 255;
(works both on big and little endian systems)
Jonas
I think a simple cast to Byte should be enough and cross-endianess.
PROGRAM LSB;
function least_significant_byteof (num: integer): byte; BEGIN least_significant_byteof := num AND $FF; END; { least_significant_byteof }
BEGIN WriteLn(least_significant_byteof($1FF)); END.
Prof A Olowofoyeku (The African Chief) schrieb:
Hi all
Does anyone know how to return the lest significant byte of a given number? e.g. function least_significant_byteof (num: integer): byte;
An algorithm in Pascal or C would be fine.
Thanks,
On Wed, 2009-09-02 at 20:34 +0200, Olaf Ziebell wrote:
PROGRAM LSB;
function least_significant_byteof (num: integer): byte; BEGIN least_significant_byteof := num AND $FF; END; { least_significant_byteof }
BEGIN WriteLn(least_significant_byteof($1FF)); END.
Thanks. And thanks to all others who responded. I had hoped it would be something straightforward, and I am pleased to see that it is!