C89 fundamental types: minimum ranges and precision

C89 fundamental types: minimum ranges and precision

C types have minimum integer ranges and floating-point precision, not fixed widths. Use limits.h, float.h, sizeof, and CHAR_BIT to inspect the target.

CategoryCheat sheets
KindCheat sheets
C standardC89 / C90
Type Standard minimum guarantee Relevant macros Size query
char Has the same range as either signed char or unsigned char; CHAR_BIT ≥ 8. CHAR_MIN, CHAR_MAX, CHAR_BIT sizeof(char) == 1
signed char Covers at least -127 to +127. SCHAR_MIN, SCHAR_MAX sizeof(signed char) == 1
unsigned char Covers at least 0 to 255. UCHAR_MAX sizeof(unsigned char) == 1
short int Covers at least -32767 to +32767. SHRT_MIN, SHRT_MAX sizeof(short)
unsigned short int Covers at least 0 to 65535. USHRT_MAX sizeof(unsigned short)
int Covers at least -32767 to +32767; the standard does not require it to be 32-bit. INT_MIN, INT_MAX sizeof(int)
unsigned int Covers at least 0 to 65535. UINT_MAX sizeof(unsigned int)
long int Covers at least -2147483647 to +2147483647. LONG_MIN, LONG_MAX sizeof(long)
unsigned long int Covers at least 0 to 4294967295. ULONG_MAX sizeof(unsigned long)
float At least 6 decimal digits of precision; normalized positive magnitudes cover at least 1e-37 to 1e+37. FLT_DIG, FLT_MIN, FLT_MAX, FLT_EPSILON sizeof(float)
double At least 10 decimal digits of precision; normalized positive magnitudes cover at least 1e-37 to 1e+37. DBL_DIG, DBL_MIN, DBL_MAX, DBL_EPSILON sizeof(double)
long double Precision and range are at least those of double: at least 10 decimal digits and normalized positive magnitudes covering 1e-37 to 1e+37. LDBL_DIG, LDBL_MIN, LDBL_MAX, LDBL_EPSILON sizeof(long double)

▶ Example

Edit the C code below and click Run; the server compiles and executes it:

Output:

Output is implementation-dependent: the macros and sizeof expressions report the actual target values, so no fixed numbers are assumed.
ℹ️ Info sizeof(char) is always 1, but a C byte need not have 8 bits; inspect CHAR_BIT. sizeof(T) * CHAR_BIT gives the number of bits in the object representation, which may include padding, so limits.h remains authoritative for value ranges.
ℹ️ Info In float.h, FLT_MIN, DBL_MIN, and LDBL_MIN are the smallest normalized positive values, not the most negative values. The corresponding MAX macros are the largest finite values, and EPSILON describes resolution near 1.
💡 Tip In C89, convert a sizeof result of type size_t to unsigned long and print it with %lu; C99 and later can use %zu directly.

📚 Related Tutorials

❓ FAQ

QIs int always 32-bit in C?
ANo. The standard only requires int to cover at least -32767 through 32767. Implementations may use 16, 32, or another width; inspect INT_MIN, INT_MAX, and sizeof(int), and do not infer the value range from sizeof alone.
QWhy is the standard minimum LONG_MIN listed as -2147483647 when many platforms show -2147483648?
AThe minimum guarantee accommodates signed representations such as ones' complement and sign-and-magnitude, giving the symmetric bound -2147483647. Common two's-complement implementations represent one extra negative value, allowing LONG_MIN to be -2147483648; that is an implementation property, not the universal minimum guarantee.
QDoes sizeof(char) == 1 mean that a byte has 8 bits?
ANo. sizeof(char) is 1 by definition, but the number of bits in a C byte is implementation-defined; check CHAR_BIT in limits.h. sizeof(T) * CHAR_BIT gives the bits in an object's representation, which may include padding, so use the limits.h macros for value ranges.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏