According to what I’ve heard, integer values that are not the processor’s word size will be promoted when modifying them (using +, -, &, etc). The long type is supposed to the the word size. On my compiler, int is 32-bit and long is 64-bit.
Does this mean long is more efficient than int despite requiring more memory?
One more thing, do compound operators also promote the values? And what about the increment and decrement operators?
It doesn’t matter, this isn’t something you can control. Choose the narrowest type which is wide enough to represent the values you need. This is the best you can do under any and all circumstances.
The language guarantees the result of operations will be correct, and the compiler will choose the most efficient path to that result that it can find. This may involve changing integer sizes at some stage, or may not.
The processor may do its own internal transformations. Again, without changing the result. Again, it’s out of your hands.