09.12.2012 Views

Basic Characteristics RAPID

Basic Characteristics RAPID

Basic Characteristics RAPID

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Expressions <strong>Basic</strong> <strong>Characteristics</strong> <strong>RAPID</strong><br />

7 Expressions<br />

An expression specifies the evaluation of a value. It can be used, for example:<br />

7.1 Arithmetic expressions<br />

- in an assignment instruction e.g. a:=3*b/c;<br />

- as a condition in an IF instruction e.g. IF a>=3 THEN ...<br />

- as an argument in an instruction e.g. WaitTime time;<br />

- as an argument in a function call e.g. a:=Abs(3*b);<br />

An arithmetic expression is used to evaluate a numeric value.<br />

Example: 2*pi*radius<br />

Table 2 shows the different types of operations possible.<br />

Table 2<br />

Operator Operation Operand types Result type<br />

+ addition num + num num 3)<br />

+ unary plus; keep sign +num or +pos same 1)3)<br />

+ vector addition pos + pos pos<br />

- subtraction num - num num 3)<br />

- unary minus; change sign -num or -pos same 1)3)<br />

- vector subtraction pos - pos pos<br />

* multiplication num * num num 3)<br />

* scalar vector multiplication num * pos or pos * num pos<br />

* vector product pos * pos pos<br />

* linking of rotations orient * orient orient<br />

/ division num / num num<br />

DIV 2)<br />

MOD 2)<br />

integer division num DIV num num<br />

integer modulo; remainder num MOD num num<br />

1. The result receives the same type as the operand. If the operand has an alias<br />

data type, the result receives the alias "base" type (num or pos).<br />

2. Integer operations, e.g. 14 DIV 4=3, 14 MOD 4=2.<br />

(Non-integer operands are illegal.)<br />

3. Preserves integer (exact) representation as long as operands and result are kept<br />

within the integer subdomain of the num type.<br />

5-26 <strong>RAPID</strong> Reference Manual

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!