HP 3000 Manuals

OVFLCHECK [ HP Pascal/iX Reference Manual ] MPE/iX 5.0 Documentation


HP Pascal/iX Reference Manual

OVFLCHECK 

OVFLCHECK is an HP Pascal Option.

When the OVFLCHECK compiler option is ON, the compiler generates overflow
checking code for all integer arithmetic operations.  Overflow-checking
code stops the program and issues an error message if an arithmetic
operation results in an integer overflow.

Syntax 

$OVFLCHECK {ON }$
           {OFF}

Default       ON.

Location      Anywhere, but it affects an entire statement at a time.  If
              OVFLCHECK is ON when the compiler processes a statement
              terminator, then all arithmetic operations in the statement
              are checked for overflow at run time.  The OVFLCHECK option
              stays ON or OFF until another OVFLCHECK option overrides
              it.

When OVFLCHECK is OFF, integer overflows are not detected.  One use for
this is in a random number generator, when overflows are expected and are
to be ignored.


NOTE This option can be used to turn off overflow for bit32 multiplication; this option has no effect on bit52 or longint multiplication.
Example PROGRAM t (output); MODULE rand; EXPORT FUNCTION random : integer; PROCEDURE init_random (seed, range : integer); IMPLEMENT CONST multiplier = 31415821; VAR rand_seed, rand_range : integer; PROCEDURE init_random (seed, range : integer); BEGIN rand_seed := seed; rand_range := range; END; FUNCTION random : integer; BEGIN $PUSH, OVFLCHECK OFF$ rand_seed := (rand_seed * multiplier +1) MOD rand_range; $POP$ random := rand_seed; END; END; IMPORT rand; BEGIN init_random(1234567,1000); writeln(random); writeln(random); writeln(random); END.


MPE/iX 5.0 Documentation