Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

The long integer type

long is a signed integer type equivalent to long int. Do not assume that it has exactly 64 bits.

Version: C23; repository compiler flag, production runtime not attested

Syntax

long name;
long int name;
signed long name;
unsigned long name;

long, long int, and signed long int name the same type. In C23 its range includes at least −2147483648 through 2147483647. Implementation limits are available as LONG_MIN and LONG_MAX in <limits.h>.

long need not be larger than int. unsigned long is a separate unsigned type; long long is another integer type, while long double is floating-point.

Signed arithmetic overflow has undefined behavior. The L suffix in 30000L selects long here. For decimal output with printf, use %ld or %li for long, and %lu for unsigned long.

Examples

#include <stdio.h>

int main(void)
{
    long count = 30000L;
    long total = count * 2L;
    printf("%ld\n", total);
    return 0;
}

Result

60000

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources