If I write "long i = 1;
" instead of "long i = 1l;
", will the 1
be recognized as int
and then implicitly converted to long
?
Edit: Thank you all. I see there's no type conversion. Is this also the case with the suffix u
(like 10u
)? Then what's the use of those l
and u
?
The compiler will see what you are trying to assign and set the value to 1 immediately. There is no type conversion that happens with a literal. Even if you said long x = 1.0, you won't see a runtime type conversion.
By the way, on Windows, long and int are the same so there wouldn't be a type conversion anyway.
[Edit: made last comment specific to Windows; removed reference to preprocessor]