-
constants of long
I read that one should always suffix long constants with L.
So whats the difference between the following two examples:
Code:
long x = 100L; // no L
x = x * 2L; // no L
Code:
long x = 100; // no L
x = x * 2; // no L
I dont see what the problem could ever be with the second form
-
To start, depending on your machine, there may or may not be a difference between int and long. If there is no difference, then this conversation is a moot point.
If there is a difference between int and long on your machine, then that's the difference, and long would use 8 bytes to hold a value and int would use 4.
For all practical purposes, for your example, since x is defined as long, the end result is the same.
To see any differences, you would need to view the generated assembler source, and be able to understand assembler, to see the difference.