Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

write 16bit smallint high/low 8bit

Status
Not open for further replies.

polytechnician

Programmer
Mar 25, 2015
1
DK
I want to build up a signed small int writing the low byte and high byte separately.

I have done this many times using the absolute directive but for some reason my Codegear 2009 delphi are playing tricks on me.

If the result is negative I just get a large wrong number. I think the compiler uses 32bit even the smallint is only 16bit


Var
ByteData : array [0..1] of byte;
signed16: smallint absolute ByteData;

begin
....
ByteData[0] := ord(temp[1]);
....
ByteData[1] := ord(temp[1]);

Signed16; // result only correct if positive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top