现在的位置: 首页 > 综合 > 正文

c_integer_constant_suffix

2014年03月16日 ⁄ 综合 ⁄ 共 2008字 ⁄ 字号 评论关闭

Double-Word Integers

ISO C99 supports data types for integers that are at least 64 bits wide, and as an extension GCC supports them in C89 mode. Simply write long long int for a signed integer, or unsigned long long int for an unsigned integer. To
make an integer constant of type long long int, add the suffix LL to the integer.
To make an integer constant of type unsigned long long int, add the suffix ULL to the integer.

You can use these types in arithmetic like any other integer types. Addition, subtraction, and bitwise boolean operations on these types are open-coded on all types of machines, as well as shifts with a constant value. Multiplication, division and shifts are
not open-coded and use special library routines.

There may be pitfalls when you use long long types for function arguments, unless you declare function prototypes. If a function expects type int for its argument, and you pass a value of type long long int, confusion will result because the caller and the
subroutine will disagree about the number of bytes for the argument. Likewise, if the function expects long long int and you pass int. The best way to avoid such problems is to use prototypes.

Integer Constants

There are various integer data types, for short integers, long integers, signed integers, and unsigned integers. You can force an integer constant to be of a long and/or unsigned integer type by appending a sequence of one or more letters to the end of the
constant:

u
U
    Unsigned integer type.
l
L
    Long integer type.

For example, 45U is an unsigned int constant. You can also combine letters: 45UL is an unsigned long int constant. (The letters may be used in any order.)

Both ISO C99 and GNU C extensions add the integer types long long int and unsigned long long int. You can use two ‘L’s to get a long long int constant; add a ‘U’ to that and you have an unsigned long long int constant. For example: 45ULL.

http://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Constants

http://tigcc.ticalc.org/doc/gnuexts.html

http://stackoverflow.com/questions/2958007/what-does-the-l-mean-at-the-end-of-an-integer-literal

http://msdn.microsoft.com/en-us/library/00a1awxf.aspx

http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fconref.htm

http://www.cplusplus.com/doc/tutorial/constants/

抱歉!评论已关闭.