Type Qualifiers

The fundamental data types may be modified by the prefixes signed, unsigned, short, and long. These modifications change the range of values that can be represented by the fundamental data type.

Modified Integer Types

Qualified Type Min Max Size (Bits)
unsigned char 0 255 8
char, signed char -128 127 8
unsigned short int 0 65535 16
short int, signed short int -32768 32767 16
unsigned int 0 65535 16
int, signed int -32768 32767 16
unsigned long int 0 232-1 32
long int, signed long int -231 231-1 32
unsigned long long int 0 264-1 64
long long int, signed long long int -263 263-1 64

The keyword int is optional when it is modified (shown in italics in table above). For example, an unsigned int could be specified more simpy as unsigned. The only time int must appear is when used by itself.

Also note that the fundamental data types are all signed by default. So int and signed int mean exactly the same thing. signed is not required, but often used when one wants to make their code explicitly clear.

Some compilers, such as the legacy MPLAB® C18 compiler, support the apparently contradictory short long which is typically defined to be 24-bits. This data type is usually found on compilers that support digital signal processors where 24-bit data is used in high-end audio applications.

As with the fundamental data types, the sizes shown in the table above may vary from one compiler to the next. For example, the short modifier has no effect on int with the MPLAB XC16 compiler, while the MPLAB XC32 compiler defines a short as 16-bits versus the full int as 32-bits.

Modified Floating-Point Types

On the floating point side of data types the only valid qualifier is long and it is typically used only with double.

Qualified Type Absolute Min Absolute Max Size (Bits)
float ±~10-44.85 ±~1038.53 32
double ±~10-44.85 ±~1038.53 32
long double ±~10-323.3 ±~10308.3 64

Most compilers define float and double as shown in the table above, while some allow long to be applied to float and double. The data above is representative of the MPLAB XC16 compiler, but should be similar for all IEEE-754 format floating point implementations.

Some compilers provide a setting or command line switch that will force double to behave as long double in the table.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.