Arithmetic Operators

Arithmetic operators, which take real or integer operands, include +, -, *, /, div, and mod. Binary Arithmetic Operators

Operator Operation Operand Types Result Type Example

+ addition integer, real

integer, real

X + Y

- subtraction integer, real

integer, real

Result - 1

* multiplication integer, real

integer, real

P * InterestRate

/ real division integer, real

real

X / 2

div integer divisioninteger

integer

Total div UnitSize

mod remainder integer

integer

Y mod 6

Unary arithmetic operators

Operator Operation Operand Type

Result Type

Example

+ sign identity integer, real

integer, real

+ 7

- sign negationinteger, real

integer, real

-X

The following rules apply to arithmetic operators.

• The value of x / y is of type Extended, regardless of the types of x and y. For other arithmetic operators, the result is of type Extended whenever at least one operand is a real; otherwise, the result is of type Int64 when at least one operand is of type Int64; otherwise, the result is of type

Integer. If an operand's type is a subrange of an integer type, it is treated as if it were of the integer type.

  • The value of x div y is the value of x / y rounded in the direction of zero to the nearest integer.
  • The mod operator returns the remainder obtained by dividing its operands. In other words, x mod y = x (x div y) * y.
  • A runtime error occurs when y is zero in an expression of the form x / y, x div y, or x mod y.
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment