Question: Mathematical Operations Between Constants
#6

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
The preprocessor will simply change MAX_PLAYERS to 500 and MAX_VEHICLES to 2000 before compiling there is no optimization, the only benefit you get is the values can be changed in one place which will affect the code anywhere those defines are used. So really the only optimization is saving you coding time by changing one value instead of potentially hundreds.
That's what I'm asking, if it will simply replace it with 500 and 2000 or compile it as 1000000 and not as 500 * 2000.

Quote:
Originally Posted by MattyG
Посмотреть сообщение
Yes, that would be correct. If you then used x elsewhere in the code, it would be equal to 1000000
No that's not what I'm asking, I know it will be 1000000, read my post again...

Quote:
Originally Posted by MP2
Посмотреть сообщение
What he's asking is, does the compiler interpret that as a constant expression (right word?) and make it 1000000, or does it store the multiplication and process that every time 'x' is declared.

I'm not sure.
Not quite what I asked.

I wanted to ask if the compiler will have to calculate the operation between the constants when I want to assign it to x, or if it will replace it as 1000000 and assign it to x.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)