Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the L at the end of a number do? [duplicate]

Tags:

c++

I have this constant:

#define MAX_DATE  2958465L

What does the L mean in this sense?

like image 482
Tony The Lion Avatar asked Nov 24 '22 22:11

Tony The Lion


2 Answers

It is a long integer literal.

Integer literals have a type of int by default; the L suffix gives it a type of long (Note that if the value cannot be represented by an int, then the literal will have a type of long even without the suffix).

like image 172
James McNellis Avatar answered Nov 27 '22 13:11

James McNellis


In this scenario the Ldoes nothing.

The L after a number gives the constant the long type, but because in this scenario the constant is immediately assigned to an int variable nothing is changed.

like image 37
orlp Avatar answered Nov 27 '22 13:11

orlp