[fpc-pascal] subtract longwords with rollover
Klaus Hartnegg
hartnegg at gmx.de
Thu Nov 28 18:12:07 CET 2013
Sorry, I forgot to mention there is {$Q-} in the source.
The trick was indeed to use dec(longint(a),b). However I had missed one
place in the code, so I got another runtime error from there.
But why does it only work with longint, and not with longword?
This looks like a missing declaration of one variant of the dec function.
var
a,b : longword;
i,j : byte;
begin
{$Q-}
for i := 0 to 4 do begin
for j := 0 to 4 do begin
write (i,' ',j,' ');
a := longword(j) * 1000000000;
b := longword(i) * 1000000000;
write (a:10,' ',b:10,' ');
{ a := a-b; } { fail at 1 0 }
{ dec (a,b); } { fail at 1 0 }
dec (longint(a),b); { ok }
writeln (a:11);
end;
end;
end.
More information about the fpc-pascal
mailing list