DIffrences

Jan 14, 2014 at 6:06pm
what is the difference between regular variable declaration and
forcing integer literals like this
1
2
3
4
5
6
7
8
  75         // int
75u        // unsigned int
75l        // long
75ul       // unsigned long 
75lu       // unsigned long 


long foo = 75
Last edited on Jan 14, 2014 at 6:06pm
Jan 14, 2014 at 6:14pm
The difference is that it changes the type of the literal.

http://ideone.com/N1zAyL

Also, you have to use l or ul or u to be allowed to write some large literals.
Last edited on Jan 14, 2014 at 11:35pm
Jan 14, 2014 at 6:16pm
in both cases the type is long.. why would i write in my code 75L instead of long foo = 75;?
Last edited on Jan 14, 2014 at 6:16pm
Jan 14, 2014 at 6:18pm
Did you even look at the link I posted?
Jan 14, 2014 at 6:19pm
The type is different. Note that if the type is not big enough it will use a larger type anyway. E.g. if you write 123456789012L and the number 123456789012 is too large to be stored by type long but long long is big enough it will use long long instead.
Last edited on Jan 14, 2014 at 6:29pm
Topic archived. No new replies allowed.