Go to main content
Oracle® Developer Studio 12.6: C User's Guide

Exit Print View

Updated: July 2017
 
 

2.7 long long Data Type

When you compile with -std=c89, the Oracle Developer Studio C compiler includes the data types long long and unsigned long long, which are similar to the data type long. The long long data type stores 64 bits of information; long stores 32 bits of information when compiling with -m32. The long data type stores 64 bits when compiling with -m64. The long long data type is not available in -std=c89 -pedantic (a warning is issued).

2.7.1 Printing long long Data Types

To print or scan long long data types, prefix the conversion specifier with the letters ll. For example, to print llvar, a variable of long long data type, in signed decimal format, use:

printf("%lld\n", llvar);

2.7.2 Usual Arithmetic Conversions

Some binary operators convert the types of their operands to yield a common type, which is also the type of the result. These conversions are called the usual arithmetic conversions. For -std=c11 and -std=gnu11, the usual arithmetic conversions are defined in the 9899:2011 ISO/IEC C Programming Language standard. For -std=c99 and -std=gnu99 the usual arithmetic conversions are defined in the 9899:1999 ISO/IEC C Programming Language standard. For -std=c89 and -std=gnu89, when -pedantic is in effect, the usual arithmetic conversions are defined in the 9899:1990 ISO/IEC C Programming Language. For -Xs or -std=c89 and -gnu89, when -pedantic=no is in effect, the usual arithmetic conversions are defined as follows:

  • If either operand is type long double, the other operand is converted to long double.

  • Otherwise, if either operand has type double, the other operand is converted to double.

  • Otherwise, if either operand has type float, the other operand is converted to float.

  • Otherwise, the integral promotions are performed on both operands. Then, these rules are applied:

    • If either operand has type unsigned long long int, the other operator is converted to unsigned long long int.

    • If either operand has type long long int, the other operator is converted to long long int.

    • If either operand has type unsigned long int, the other operand is converted to unsigned long int.

    • Otherwise, when you compile with –m64, if one operand has type long int and the other has type unsigned int, both operands are converted to unsigned long int.

    • Otherwise, if either operand has type long int, the other operand is converted to long int.

    • Otherwise, if either operand has type unsigned int, the other operand is converted to unsigned int.

    • Otherwise, both operands have type int.