polytechnician
Programmer
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
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