Blog Datasheets Home About me Clients My work Services Contact

G2Labs Grzegorz Grzęda

libc - limits header

June 26, 2023

Definition of limits of standard data types.

Limits for floating-point types are defined in <float.h>. Limits for width-specific integral types and other typedefs are defined in <stdint.h>.

1
#include <limits.h>

Macro definitions

Please note - all these definitions are implementation/platform dependent. These values are true for x32/x64 platform.

nameexpressionpossible value
CHAR_BITNumber of bits in a char object (byte)8 or greater
SCHAR_MINMinimum value for an object of type signed char-127 (-27 + 1) or less
SCHAR_MAXMaximum value for an object of type signed char127 (27 - 1) or greater
UCHAR_MAXMaximum value for an object of type unsigned char255 (28 - 1) or greater
CHAR_MINMinimum value for an object of type chareither SCHAR_MIN or 0
CHAR_MAXMaximum value for an object of type chareither SCHAR_MAX or UCHAR_MAX
MB_LEN_MAXMaximum number of bytes in a multibyte character, for any locale1 or greater
SHRT_MINMinimum value for an object of type short int-32767 (-215 + 1) or less
SHRT_MAXMaximum value for an object of type short int32767 (215 - 1) or greater
USHRT_MAXMaximum value for an object of type unsigned short int65535 (216 - 1) or greater
INT_MINMinimum value for an object of type int-32767 (-215 + 1) or less
INT_MAXMaximum value for an object of type int32767 (215 - 1) or greater
UINT_MAXMaximum value for an object of type unsigned int65535 (216 - 1) or greater
LONG_MINMinimum value for an object of type long int-2147483647 (-231 + 1) or less
LONG_MAXMaximum value for an object of type long int2147483647 (231 - 1) or greater
ULONG_MAXMaximum value for an object of type unsigned long int4294967295 (232 - 1) or greater
LLONG_MINMinimum value for an object of type long long int-9223372036854775807 (-263 + 1) or less
LLONG_MAXMaximum value for an object of type long long int9223372036854775807 (263 - 1) or greater
ULLONG_MAXMaximum value for an object of type unsigned long long int18446744073709551615 (264 - 1) or greater


➡️ Testing strategies for clean code in C and Python


⬅️ Refactoring legacy code using clean code principles in C and Python


Go back to Posts.