Microchip Technology SW006023-2N Data Sheet

Page of 238
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.
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
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.
6.4.2
limits.h
The limits.h header file defines the ranges of values which can be represented by 
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.
SCHAR_MIN
-128
The minimum value possible for an object of 
type
 signed char
.
SCHAR_MAX
127
The maximum value possible for an object of 
type 
signed char
.
UCHAR_MAX
255
The maximum value possible for an object of 
type 
unsigned char
.
CHAR_MIN
The minimum value possible for an object of 
type 
char
.
CHAR_MAX
The maximum value possible for an object of 
type 
char
.
MB_LEN_MAX
16
The maximum length of multibyte character in 
any locale.
SHRT_MIN
-32768
The minimum value possible for an object of 
type 
short int
.
SHRT_MAX
32767
The maximum value possible for an object of 
type 
short int
.
USHRT_MAX
65535
The maximum value possible for an object of 
type 
unsigned short int
.