long Long integer type
long Long integer type
long means long int, with at least int's range and -2147483647..2147483647. It may be 32 or 64 bits, uses L literals and %ld, and may equal int's width.
| Category | Type specifiers |
|---|---|
| Kind | Keyword / Statement |
| C standard | C89 / C90 |
📝 Syntax
long l = 100000L;
▶ Example
Edit the C code below and click Run; the server compiles and executes it:
Output:
total = 125000
🏷️ Related type specifiers
📚 Related Tutorials
❓ FAQ
QDoes long always occupy more bytes than int?
ANot necessarily. long has a higher minimum range requirement, but in many 32-bit ABIs both long and int are 32 bits, so sizeof(long) can equal sizeof(int).
QWhy does long have different widths on 64-bit Windows and Linux?
ACommon 64-bit Windows environments use LLP64, keeping long at 32 bits, while many Unix-like systems use LP64, making long 64 bits. This is an ABI choice, not a consequence of CPU width alone.
QWhich printf format should be used for long?
AUse %ld for long and %lu for unsigned long. A mismatch between the format and argument type causes undefined behavior. For long long, use %lld or %llu as appropriate.