Microchip Technology SW006023-2N Data Sheet
MPLAB
®
XC32 C/C++ Compiler User’s Guide
DS51686E-page 94
2012 Microchip Technology Inc.
6.4
INTEGER DATA TYPES
Integer values in the compiler are represented in 2’s complement and vary in size from
8 to 64 bits. These values are available in compiled code via limits.h.
8 to 64 bits. These values are available in compiled code via limits.h.
6.4.1
Signed and Unsigned Character Types
By default, values of type plain char are signed values. This behavior is
implementation-defined by the C standard, and some environments
implementation-defined by the C standard, and some environments
1
define a plain
C/C++ char value to be unsigned. The command line option -funsigned-char can
be used to set the default type to unsigned for a given translation unit.
be used to set the default type to unsigned for a given translation unit.
6.4.2
limits.h
The limits.h header file defines the ranges of values which can be represented by
the integer types.
the integer types.
Type
Bits
Min
Max
char
,
signed char
8
-128
127
unsigned char
8
0
255
short
,
signed short
16
-32768
32767
unsigned short
16
0
65535
int
,
signed int
,
long
,
signed long
32
-2
31
2
31
-1
unsigned int
,
unsigned long
32
0
2
32
-1
long long
,
signed long long
64
-2
63
2
63
-1
unsigned long long
64
0
2
64
-1
1. Notably, PowerPC and ARM.
Macro name
Value
Description
CHAR_BIT
8
The size, in bits, of the smallest non-bit field
object.
object.
SCHAR_MIN
-128
The minimum value possible for an object of
type
type
signed char
.
SCHAR_MAX
127
The maximum value possible for an object of
type
type
signed char
.
UCHAR_MAX
255
The maximum value possible for an object of
type
type
unsigned char
.
CHAR_MIN
-128 (or 0, see
Section 6.4.1 “Signed
and Unsigned
Character Types”)
Section 6.4.1 “Signed
and Unsigned
Character Types”)
The minimum value possible for an object of
type
type
char
.
CHAR_MAX
127 (or 255, see
Section 6.4.1 “Signed
and Unsigned
Character Types”)
Section 6.4.1 “Signed
and Unsigned
Character Types”)
The maximum value possible for an object of
type
type
char
.
MB_LEN_MAX
16
The maximum length of multibyte character in
any locale.
any locale.
SHRT_MIN
-32768
The minimum value possible for an object of
type
type
short int
.
SHRT_MAX
32767
The maximum value possible for an object of
type
type
short int
.
USHRT_MAX
65535
The maximum value possible for an object of
type
type
unsigned short int
.