Sun Studio 12 Update 1: C User's Guide
この本のみを検索
PDF 文書ファイルをダウンロードする (2106 KB)

2.6 long long Data Type

When you compile with -xc99=none, the Sun 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 on SPARC V8 and x86. The long data-type stores 64 bits on SPARC V9. The long long data-type is not available in -Xc mode.

2.6.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.6.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 are called the usual arithmetic conversions:

  • 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 on SPARC V9 only and specify cc -xc99=none, 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.