Tuesday, July 06, 2004

c/c++ : operator concepts

presedence must be known
http://www.swansontec.com/sopc.htm
http://docs.roxen.com/pike/7.0/tutorial/expressions/operator_tables.xml

n + n + ++n = ??

for + associativity is left to right ie
n + n + ++n = (n + n) + ++n = whatever

in ( a + b ), b is evaluated first
++n + n v/s n + ++n

constants creates all the problem
0 + n + ++n = ??

constants are removed aside and than variables are evaluated.
ie 0 + n + ++n = 0 + ( n + ++n)

* sucks a lot
i * ++i * i++ = ??

unirary operatos are evaluated first, and then for the * expression the variable are used. ie in the above expression. ( left to right associativity and right evaluated first rules holds)
the steps are : (according to my interpretation, and works well for my compiler)
++i
i++
i * i * i

f***ing na!!