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.

CategoryType specifiers
KindKeyword / Statement
C standardC89 / C90

📝 Syntax

long l = 100000L;

▶ Example

Edit the C code below and click Run; the server compiles and executes it:

Output:

total = 125000

📚 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.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏