[fpc-pascal] subtract longwords with rollover

Klaus Hartnegg hartnegg at gmx.de
Thu Nov 28 17:37:39 CET 2013


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.

HELP!

Thanks,
Klaus



More information about the fpc-pascal mailing list