Contents | Prev | Next | Index


Arithmetic Operators

+ sum
- difference
* product
/ real quotient
DIV integer quotient
MOD modulus

The operators +, -, * and / apply to operands where both of them are of integer types or subranges thereof. They also apply to operands with both of them being of  real types. The result type is the one that includes the types of both operands. If the operator is / then the result type is always DOUBLE. If the compiler switch or the comment-embedded directive for stricter type checking is not activated then the operands may be of mixed integer and real types.

When used as unary operators, - denotes sign inversion and + denotes the identity operation. A sign inversion applies to an signed integer or real operand only.

The operators DIV and MOD apply to operands which are both of integer types only. The result type is the one that includes the types of the both operands. They are related by the following formulas, defined for any x and positive divisor y:

  x = (x DIV y) * y + (x MOD y)
  0 <= (x MOD y) < y

Examples:

 
x y x DIV y x MOD y
5 3 1 2
-5 3 -2 1


Contents | Prev | Next | Index

Canterbury Pascal for JVM  (Last documentation update Sep 02, 2004)
Copyright © 1999-2004 J.Neuhoff - mhccorp.com  . All rights reserved.
Please send any comments or corrections to neuhoff@mhccorp.com