Please enable JavaScript to view this site.

Validity: Rule, Task

In general, these operators work between integer or real quantities.

If a real quantity is assigned to a variable of integer type, the decimal digits are truncated.

If the value is too large to be represented in the integer variable, the result will be unpredictable.

When an arithmetical operator combines a real with an integer, the result is converted to a real.

Addition

Sum operator between two numerical quantities.

Syntax

valueA + valueB

valueA

First addend value

valueB

Second addend value

Result

The sum of the two values

Examples:

; The register rr(12) will contain the sum of the current position of axis 2 cp(2)

; and the contents of register rr(3)

rr(12) = cp(2) + rr(3)

; It can also be used as a sign (unary) operator.

; The register r(12) will contain the value +3

r(12) = +3

NOTE: To sum (concatenate) strings, use the operator #.

Subtraction

Subtraction operator between numerical quantities.

Syntax

valueA - valueB

valueA

Value of the minuend

valueB

Value of the subtrahend

Result

The difference between minuend and subtrahend

Examples:

; The register rr(12) will contain the difference between the contents of the register r(2)

; and the contents of the variable remainder

rr(12) = r(2) - remainder

; It can also be used as a sign (unary) operator.

; The register r(12) will contain the value -3

r(12) = -3

Multiplication

Multiplication operator between numerical quantities.

Syntax

valueA * valueB

valueA

Value of the first factor

valueB

Value of the second factor

Result

The multiplication between the factors

Examples:

; The register rr(12) will contain the product between the constant K_PI (Pi)

; and the variable diameter

rr(12) = K_PI * diameter

Division

Division operator between numerical quantities.

Syntax

valueA / valueB

valueA

Dividend value

valueB

Value of the divisor (different from 0)

Result

The division between dividend and divisor

NOTE: In the case of division between integers, the result is only the integer part of the division even if the destination is a real quantity.

Examples:

; The register rr(12) will contain the quotient between the value 2.0 and the 

; variable "value" in turn divided by the variable "remainder"

REAL value = 10.0

REAL remainder = 0.5

rr(12) = (2.0 / value) / remainder

 

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Contents: ALT+c
Search: ALT+s
Exit Menu/Up: ESC