Implementation-defined Limits: <b>limits.h</b>




Document: The C Standard Library

next Error Conditions: errno.h
up The C Standard Library
gif Mechanics

Implementation-defined Limits: limits.h

The header file limits.h essentially just provides #define directives defining symbolic constants for the maximum and minimum values allowed with the standard C integral data types - i.e. it does not provide any function prototypes as such. It is important to be able to refer to these values in your programs in order to prevent, or at least detect, overflow situations. The values potentially differ from one C compiler to another (hence "implementation-defined"), but the symbolic constants defined in limits.h always have the same names. Thus by using the symbolic constants to refer to these limits it should be possible to write your programs in such a way that they will automatically adjust to whatever the limits actually are with any particular compiler.

Some constants which are commonly used are:

INT_MAX :
maximum value of int
INT_MIN :
minimum value of int
LONG_MAX :
maximum value of long
LONG_MIN :
minimum value of long
UINT_MAX :
maximum value of unsigned int
ULONG_MAX :
maximum value of unsigned long

This is not an exhaustive list: examine a copy of limits.h for yourself to see others. However, note that there is, of course, no need for constants called, say, UINT_MIN or ULONG_MIN since these minima are always guaranteed to be simply zero.




Document: The C Standard Library

next Error Conditions: errno.h
up The C Standard Library
gif Mechanics



McMullin@eeng.dcu.ie
Fri Mar 29 14:35:38 GMT 1996