This question is impossible to answer universally in a sense whether long
is faster than int
.
The code could be ran on a 16-bit platform with 32-bit long
and 16-bit int
on which the int
would probably be faster - but not necessarily. On the other hand, on a native 32-bit platform which has 32-bitint
and 64-bit long
, the long
could be faster - but not necessarily.
So it is platform dependent, and compiler dependent. The bottom line is that usually the operations on target CPU's native word length types are no slower(usually faster) than the operations which may require casting the width to native size.