tags:

views:

173

answers:

2

in mplab ide what is the size of data types (int,unsigned int,float ,unsignedfloat,char.....)

A: 

This is hard without knowing for which CPU you want to compile code. Assuming e.g. Microchip's C18 compiler for the PIC18, the User Guide states the following fundamental type sizes:

TYPE                SIZE     RANGE
char(1,2)            8 bits  -128 127
signed char          8 bits  -128 127
unsigned char        8 bits  0 255
int                 16 bits  -32,768 32,767
unsigned int        16 bits  0 65,535
short               16 bits  -32,768 32,767
unsigned short      16 bits  0 65,535
short long          24 bits  -8,388,608 8,388,607
unsigned short long 24 bits  0 16,777,215
long                32 bits  -2,147,483,648 2,147,483,647
unsigned long       32 bits  0 4,294,967,295

Note that this includes some types (short long) that are not standard in C.

unwind
Can I suggest that you state that these values are for Microchip's C18 compiler for the PIC18 family? I know the linked user guide provides that information, but it would make this answer more complete to include it here as well. Also, given that the question doesn't specify a compiler and target microcontroller, it should be stressed that the types may be different sizes for other targets.
Steve Melnikoff
+1  A: 

I would be wary of such generalizations. MPLAB is just an IDE - it is suitable for different chips. Microchip has 8-bit controllers like PIC18F, 16-bit and 32-bit controllers. The data types for each may be different and hold serious implications for performance. I.e. for the 8-bit chips the 16 and 32 bit data types may be emulated in software, which isn't always what you want.

Eli Bendersky