Question: Mathematical Operations Between Constants
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
Yes, in most cases, but it isn't very clever so some times you have to help it out. Also, I don't think it does ANY optimisations on floats (but you can check).

This is why you can do:

pawn Код:
case 8 * 8:
But not:

pawn Код:
case 8 * a:
Unless "a" is actually declared as "const", in which case the compiler can actually sometimes optimise that too.

Doing this:

pawn Код:
new b = a * 10 + 5
Will NOT optimise because you need "a" before any evaluation can be done. Even something like this will not optimise (again, I don't think) because of operator ordering:

pawn Код:
new b = a * 10 / 2;
But this will because the order has been forcibly changed:

pawn Код:
new b = a * (10 / 2);
Thank you very much!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)