What is supposed to happen if the 2nd argument is negative?
program Project1;
uses sysutils;
var a: LongInt;
begin
a := StrToInt('-1');
WriteLn(2 << a);
WriteLn(2 << -1);
ReadLn;
end.
prints:
0
4294967296
"2 << a" translates to "shl eax,cl" (cl being loaded with the result
from strtoint)
So at least my cpu thinks the result is 0. (I guess unsigned byte(-1)
makes it "2 << 255")
But the compiler (3.1.1) pre-evaluating the constant, comes to a diff
result.
_______________________________________________
fpc-devel maillist - [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel