integer literal
From cppreference.com
Contents |
[edit] Syntax
[0-9]+ type_suffix | (1) | ||||||||
0 [0-7]+ type_suffix | (2) | ||||||||
0 x [0-9a-b]+ type_suffix | (3) | ||||||||
[edit] Explanation
- Decimal notation
- Octal notation
- Hexadecimal notation
[edit] 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
[edit] Notes
- Letters in integer constants are case-insensitive.
[edit] 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)