What is the largest data type for storing (and printing) an integer?

camel-man picture camel-man · Jan 10, 2012 · Viewed 35.1k times · Source

In C on a 32-bit system, which data type will store (and can therefore print) the largest integer? Is it long long or unsigned long? Is there an unsigned long long? And which is the most precise and politically correct?

Answer

wnoise picture wnoise · Jan 10, 2012

Your question is a bit unclear, but intmax_t is the largest signed integer-valued type (and uintmax_t is the largest unsigned integer type). These are typedefs defined in <stdint.h>, but if you are printing them, you need <inttypes.h> instead, and the PRInMAX macros for various values of n.