Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル

製品コード
SW006021-1
ページ / 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 144
 2012 Microchip Technology Inc.
Signed values are stored as a two’s complement integer value.
The range of values capable of being held by these types is summarized in Table 5-2 
The symbols in this table are preprocessor macros which are available after including 
<limits.h>
 in your source code. As the size of data types are not fully specified by 
the ANSI Standard, these macros allow for more portable code which can check the 
limits of the range of values held by the type on this implementation. 
The macros associated with the short long type are non-standard macros available 
in this implementation; those associated with the long long types are defined by the 
C99 Standard.
Macros are also available in <stdint.h> which define values associated with 
fixed-width types.
When specifying a signed or unsigned short int, short long int, long int 
or long long int type, the keyword int may be omitted. Thus a variable declared 
as short will contain a signed short int and a variable declared as unsigned 
short
 will contain an unsigned short int.
It is a common misconception that the C char types are intended purely for ASCII char-
acter manipulation. However, the C language makes no guarantee that the default 
character representation is even ASCII. (This implementation does use ASCII as the 
character representation.) The char types are the smallest of the multi-bit integer 
sizes, and behave in all respects like integers. The reason for the name “char” is his-
torical and does not mean that char can only be used to represent characters. It is pos-
sible to freely mix char values with values of other types in C expressions. With the 
MPLAB XC8 C Compiler, the char types are used for a number of purposes – as 8-bit 
integers, as storage for ASCII characters, and for access to I/O locations.
TABLE 5-2:
RANGES OF INTEGER TYPE VALUES
Symbol
Meaning
Value
CHAR_BIT
Bits per char
8
CHAR_MAX
Max. value of a char
127
CHAR_MIN
Min. value of a char
-128
SCHAR_MAX
Max. value of a signed char
127
SCHAR_MIN
Min. value of a signed char
-128
UCHAR_MAX
Max. value of an unsigned char
255
SHRT_MAX
Max. value of a short
32767
SHRT_MIN
Min. value of a short
-32768
USHRT_MAX
Max. value of an unsigned short
65535
INT_MAX
Max. value of an int
32767
INT_MIN
Min. value of a int
-32768
UINT_MAX
Max. value of an unsigned int
65535
SHRTLONG_MAX
Max. value of a short long
8388607
SHRTLONG_MIN
Min. value of a short long
-8388608
USHRTLONG_MAX
Max. value of an unsigned short long 16777215
LONG_MAX
Max. value of a long
2147483647
LONG_MIN
Min. value of a long
-2147483648
ULONG_MAX
Max. value of an unsigned long
4294967295
LLONG_MAX
Max. value of a long long
2147483647
LLONG_MIN
Min. value of a long long
-2147483648
ULLONG_MAX
Max. value of an unsigned long long
4294967295