Klaus Hartnegg wrote:
Hi,

How can I subtract two longwords such that when the result becomes negative, it rolls over?

A := A - B triggers runtime error 201 when the result is negative.

dec (A,B) rolls over, but triggers runtime error 201 when A is higher than the highest possible value of longint.

Is dec only declared for longint, but not for longword?

dec(longint(A),B) fails when the result is larger than 2 billion.

I cannot use longint instead of longword, this causes problems in other parts of the code.

What happens if you explicitly disable checking using $Q- $R-

Remember that converting $80000000 to base10 might be dismal.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to