a. How does c++ compiler know what the allowed max/min values for limits on data types are?
b. Once you find the header file(s) for the question above, i need a program to display the values of any two predefined values as decimal numbers.
How does c++ compiler know what the allowed max/min values for limits on data types are?
There are C++ vendor constants for these. Each C++ compiler specifies the range of the basic types in the header %26lt;climits%26gt;
The actual values are determined so as to optimize the data types for the execution environment. Therefore, they are machine architecture-driven for high-performance.
Using limits.h, you can write a program to make use of these predefined constants as appropriate. The named constants you'll be interested in have either a _MIN or _MAX suffix. For instance:
SHRT_MIN Minimum value for an object of type short int
SHRT_MAX Maximum value for an object of type short int
USHRT_MAX Maximum value for an object of type unsigned short int
INT_MIN Minimum value for an object of type int
INT_MAX Maximum value for an object of type int
UINT_MAX Maximum value for an object of type unsigned int
LONG_MIN Minimum value for an object of type long int
LONG_MAX Maximum value for an object of type long int
ULONG_MAX Maximum value for an object of type unsigned long int
Reply:a. it's fixed during compiler construction time.
b. cout %26lt;%26lt; (int) sizeof ( ur_data_type_here )
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment