Posts: 37
Threads: 20
Joined: Nov 2006
i have an integer i (int i) and i want to compute 35*i (35 times i)
this is a multiplication
but int j=35*i doesnt work!!
what is the function to mutliply integers?
Posts: 12,072
Threads: 140
Joined: Dec 2002
it is operator *.
int i=2
int j=35*i
out j
Posts: 37
Threads: 20
Joined: Nov 2006
in fact my problem was that 100+35*i is different with 100+(35*i)
and i wanted to compute 100+(35*i)
it is strange that addition is first before mutliply (in mathematic thinking) , and at same time very logic because program compute with first operation and so on
Posts: 175
Threads: 43
Joined: Jun 2004
Wow, after 3 years using QM, I never noticed the lack of precedence in operators. I'm not sure it should be changed now. Having not planned for it, it might totally screw me!!
Matt B
Posts: 12,072
Threads: 140
Joined: Dec 2002
In QM are only 3 precedence groups of binary operators. First: + - * / % | & << >> ^ ~. Second: = != < > <= >=. Third: && ||. I don't like when there are many precedence groups, because it is not easy to remember. For example, in C++ are 10 or more precedence groups of binary operators. I don't remember them all, and then I rather use (). What is most annoying - some operators in C are placed not logically. For example, == has higher precedence than &. Anyway, now I think in QM * should have higher precedence than +, because we know it from mathematics. But now already cannot change.