Namespaces
Variants
Views
Actions

integer literal

From cppreference.com
< cpp‎ | language
Revision as of 13:36, 10 March 2013 by Bazzy (Talk | contribs)

 
 
C++ language
General topics
Flow control
Conditional execution statements
Iteration statements (loops)
Jump statements
Functions
Function declaration
Lambda function declaration
inline specifier
Exception specifications (deprecated)
noexcept specifier (C++11)
Exceptions
Namespaces
Types
Specifiers
decltype (C++11)
auto (C++11)
alignas (C++11)
Storage duration specifiers
Initialization
Expressions
Alternative representations
Literals
Boolean - Integer - Floating-point
Character - String - nullptr (C++11)
User-defined (C++11)
Utilities
Attributes (C++11)
Types
typedef declaration
Type alias declaration (C++11)
Casts
Implicit conversions - Explicit conversions
static_cast - dynamic_cast
const_cast - reinterpret_cast
Memory allocation
Classes
Class-specific function properties
Special member functions
Templates
Miscellaneous
 

Contents

Syntax

[0-9]+ Template:sparam (1)
0[0-7]+ Template:sparam (2)
0x[0-9a-f]+ Template:sparam (3)

Explanation

  1. Decimal notation
  2. Octal notation
  3. Hexadecimal notation

Types by suffix

(no suffix)
int
u
unsigned int
l
long
ul
unsigned long
ll (since C++11)
long long
ull (since C++11)
unsigned long long
User defined (since C++11)
anything

Notes

  • Letters in integer constants are case-insensitive.

Example

std::cout << 123    << '\n'
          << 0123   << '\n'
          << 0x123  << '\n'
          << 12345678901234567890UL << '\n'
          << -1u    << '\n'
          << -1ull  << '\n';

Output:

123
83
291
12345678901234567890
4294967295
18446744073709551615

(output from an x86_64 processor)