## Simple nevertheless I do not understand.....

### Simple nevertheless I do not understand.....

Hi to All
Sorry for simple question, but Perhaps today, my head is outside
of office...

Assignments
Operator Example definition
-= a-=b a:=a-b

Now, I have written little lines of code and for me this assignment don't
work.

LOCAL dwPos AS DWORD
LOCAL dwCur AS DWORD

dwPos :=10
dwCur :=15
dwCur -=dwPos+1
? dwCur // Result 4

dwCur :=15
dwCur :=dwCur-dwPos+1

? dwCur // Result 6

Why there is this difference ?

Regards Luigi De Palma

### Simple nevertheless I do not understand.....

Luigi,

It seems to me that the second expression depends on the presence and the
placement of parenthesis.

and be written like the following to match the first one :
dwCur :=15
dwCur :=dwCur-(dwPos+1)

Could be read : dwCur -=11

Pierre

### Simple nevertheless I do not understand.....

Parentheses. a -= c+d is a -= (c+d)
so, a := a-c-d or a := a - (c+d)

yes?

good luck
-- farid

outside
don't

### Simple nevertheless I do not understand.....

>

This is processed by VO based on operator precedence. Looking at C++
precedence:

Precedence Operators Function
/Associativity
17R :: global scope (unary)
17L :: class scope (binary)
16L -> . member selectors
16L [] array index
16L () function call
16L type (expr) value construction
16L 'expr'++/-- postincrement, postdecrement
16L typeid (expr) type identification
16L _cast <type> () conversion
15R sizeof size in bytes
15R ++ -- preincrement, predecrement
15R ~ bitwise NOT
15R ! logical NOT
15R + - unary minus, plus
15R (type) expr cast/coercion
15R new delete free store management
14L ->* .* member pointer selectors
13L * / % multiplicative operators
12L + - arithmetic operators
11L << >> bitwise shift
10L < <= > >= relational operators
9L == != equaltity, inequality
8L & bitwise AND
7L ^ bitwise XOR
6L | bitwise OR
5L && logical AND
4L || logical OR
3L ?: arithmetic if
2R = 'op'= assignment operators
1R throw expr exception
0L , comma operator

You see that

12L + - arithmetic operators
2R = 'op'= assignment operators

Arithmetic operators have higher precendence that assigment operators.
And arithmetic operators are processed in certain order if no grouping
is present.
Therefore
is not equal to:

Hernando "Peter"

### Simple nevertheless I do not understand.....

Luigi

Substitute the numbers - there's nothing wrong with the result
Eg

is the same as
dwCur := 15 - ( 10 + 1 )

Correct

is the same as
dwCur := 15 - 10 + 1

Correct

HTH
Steve