The predefined data type longint is an
integer in the range -263..263-1
that is stored in 64 bits. The compiler option OVFLCHECK has no
effect on 64 bit multiply.
Note that there are no longint constants
in the compiler. Therefore, numbers outside of the range minint .. maxint
can not be expressed directly. The compiler option TYPE_COERCION
must be used with a run-time computation. If the numbers are constants,
they must be typed coerced to longint so they
do not integer overflow.
Example
$standard_level 'hp_modcal'$ program prog_longint(output); var i : integer; b : longint; type rec = record case integer of 0:(l : longint); 1:(f1,f2: integer); end; const v_rec = rec[f1: hex('1'), f2: hex('ffffffff')]; { longint constant field } begin b := v_rec.l; writeln(b); try i := b; { run-time error } recover ; $push; type_coercion 'conversion'$ b := longint(1000000) * 1000000; $pop$ writeln(b); end. |
Output: