A new feature of the C++ Standard Library is an organized mechanism for describing the characteristics of the fundamental types provided in the execution environment. In older C and C++ libraries, these characteristics were often described by large collections of symbolic constants. For example, the smallest representable value that could be maintained in a character would be found in the constant named CHAR_MIN, while the similar constant for a short would be known as SHRT_MIN, for a float FLT_MIN, and so on.Two Mechanisms, One Purpose
The template class numeric_limits provides a new and uniform way of representing this information for all numeric types. Instead of using a different symbolic name for each new data type, the class defines a single static function, named min(), which returns the appropriate values. Specializations of this class then provide the exact value for each supported type. The smallest character value is in this fashion yielded as the result of invoking the function numeric_limits<char>::min(), while the smallest floating point value is found by invoking numeric_limits<float>::min(), and so on.
Solving this problem by using a template class not only greatly reduces the number of symbolic names that need to be defined to describe the operating environment, but it also ensures consistency between the descriptions of the various types.
©Copyright 1996, Rogue Wave Software, Inc.