In C++, long and long long integer literals can be represented using specific suffixes to indicate their type. Here's how they are represented:
-
Long Integer Literals:
- You can represent a long integer literal by appending the suffix
Lorlto the number. - Example:
long num1 = 1234567890L; // Long integer literal
- You can represent a long integer literal by appending the suffix
-
Long Long Integer Literals:
- For long long integer literals, append the suffix
LLorll. - Example:
long long num2 = 1234567890123456789LL; // Long long integer literal
- For long long integer literals, append the suffix
Summary:
- Use
Lorlfor long integers. - Use
LLorllfor long long integers.
These suffixes help the compiler understand the intended type of the literal, ensuring proper storage and operations. If you want to practice more with integer types in C++, consider checking out related labs on LabEx!
