Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multiply
#1
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?
#2
it is operator *.

int i=2
int j=35*i
out j
#3
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
#4
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!! Big Grin
Matt B
#5
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.


Forum Jump:


Users browsing this thread: 1 Guest(s)