Hallo,
ein "i and integer(%1111111111111111)" löscht das Vorzeichenbit. Bug oder Feature?
Robert
ein "i and integer(%1111111111111111)" löscht das Vorzeichenbit. Bug oder Feature?
Robert
Code
program bla;
{$NOSHADOW}
{ $WG} {global Warnings off}
Device = mega128, VCC=5;
{ $BOOTRST $1F000} {Reset Jump to $1F000}
Import SysTick, SerPort;
From System Import Float, Fix64;
Define
ProcClock = 16000000; {Hertz}
SysTick = 10; {msec}
StackSize = $0100, iData;
FrameSize = $0100, iData;
SerPort = 57600, Stop2; {Baud, StopBits|Parity}
RxBuffer = 8, iData;
TxBuffer = 8, iData;
Implementation
{$IDATA}
const
type
var
i : integer;
begin
EnableInts;
i := -123;
i := i and integer(%11111111 11111111); //Löscht das Vorzeichenbit. Warum?
WriteLn(SerOut, 'i = ' + IntToStr(i:8) + ' ' + IntToBin(i));
WriteLn(SerOut);
i := -123;
i := integer(word(i) and word(%11111111 11111111)); //So geht's
WriteLn(SerOut, 'i = ' + IntToStr(i:8) + ' ' + IntToBin(i));
end bla.
{$NOSHADOW}
{ $WG} {global Warnings off}
Device = mega128, VCC=5;
{ $BOOTRST $1F000} {Reset Jump to $1F000}
Import SysTick, SerPort;
From System Import Float, Fix64;
Define
ProcClock = 16000000; {Hertz}
SysTick = 10; {msec}
StackSize = $0100, iData;
FrameSize = $0100, iData;
SerPort = 57600, Stop2; {Baud, StopBits|Parity}
RxBuffer = 8, iData;
TxBuffer = 8, iData;
Implementation
{$IDATA}
const
type
var
i : integer;
begin
EnableInts;
i := -123;
i := i and integer(%11111111 11111111); //Löscht das Vorzeichenbit. Warum?
WriteLn(SerOut, 'i = ' + IntToStr(i:8) + ' ' + IntToBin(i));
WriteLn(SerOut);
i := -123;
i := integer(word(i) and word(%11111111 11111111)); //So geht's
WriteLn(SerOut, 'i = ' + IntToStr(i:8) + ' ' + IntToBin(i));
end bla.