HP Pascal/iX Reference Manual (31502-90022)

4-: 8
Real division
(/) is an exception to this restriction. If both operands
are integer or sub-integer, the compiler changes both to real numbers
prior to the division and the result is real. If both operands are
super-integers, the result is longreal because both[REV BEG] operands are
converted to longreal.[REV END]
Example
EXPRESSION RESULT
-(+10) -10 { Unary -. }
5 + 2 7 { Addition with integer operands. }
5 - 2.0 3.0 { Subtraction with implicit conversion. }
5 * 2 10 { Multiplication with integer operands. }
5.0 / 2.0 2.5 { Division with real operands. }
5 / 2 2.5 { Division with integer operands, real }
{ result. }
5.0 / 2 2.5 { Division with implicit conversion. }
5 DIV 2 2 { Division with truncation. }
5 DIV (-2) -2
-5 DIV 2 -2
-5 DIV (-2) 2
5 MOD 3 2 { Modulus. }
5 MOD (-2) error { Right operand must be positive. }
(-5) MOD 3 1 { Result is positive regardless of }
{ sign of left operand, which is }
{ parenthesized since MOD has higher }
{ precedence than -. }
{ See Operator Precedence. }
DIV
This operator returns the integer portion of the quotient of the
dividend
and the
divisor
. The dividend must be an integral-type with no range
restriction. The divisor must also be an integral-type; the divisor
cannot be 0.
Example
INPUT RESULT
413 DIV 6 68
-413 DIV 6 -68
MOD
This operator returns the
modulus
of two integers. The dividend must be
an integral-type. The divisor must also be an integral-type. If the
divisor is less than or equal to 0, an error will occur. The result is
always positive, regardless of the sign of the left operand. The left
operand must be parenthesized if it is a negative literal. MOD is
defined as:
( i - k * j )
for some integer
k
such that
0 <= i MOD j < j, j > 0
Example
INPUT RESULT
4 MOD 3 1
7 MOD 5 2
(-7) MOD 5 3
Boolean Operators
Boolean
operators perform logical functions on Boolean type operands and
produce Boolean results. The Boolean operators are NOT, AND, and OR.
When both operands are Boolean, = denotes
equivalence
, <=
implication
,
and <>
exclusive or
.