|
-
March 31st, 1999, 07:06 AM
#13
Re: Whats wrong with this code????
Ercan,
glad you found it!
Limits.h is one of the standard header files supplied with C and C++ compilers. It contains definitions for the maximum and minimum values of various implementation dependent types. These are types whose actual size is not explicitly specified by the language standard, but basically depends on the kind of system it is running on.
For example, an int is intended to be the most suitable type for holding and manipulating integers on a given system, so on a 16-bit system like Windows 3.1, an int is likely to be 16 bits, but on a 32-bit system like Windows 95 or NT, it will be 32 bits. Obviously, a 32-bit int can have far higher values than a 16-bit int. When you're writing code that needs to check for values that might overflow the maximum or minimum possible, it's useful to have these maximum and minimum values available.
The values defined in limits.h give you the size limits for these types.
Here is a typical extract from limits.h:
#if !defined(_WIN32) && !defined(_MAC)
#error ERROR: Only Mac or Win32 targets supported!
#endif
#define SHRT_MIN (-32768) /* minimum (signed) short value */
#define SHRT_MAX 32767 /* maximum (signed) short value */
#define USHRT_MAX 0xffff /* maximum unsigned short value */
#define INT_MIN (-2147483647 - 1) /* minimum (signed) int value */
#define INT_MAX 2147483647 /* maximum (signed) int value */
#define UINT_MAX 0xffffffff /* maximum unsigned int value */
#define LONG_MIN (-2147483647L - 1) /* minimum (signed) long value */
#define LONG_MAX 2147483647L /* maximum (signed) long value */
#define ULONG_MAX 0xffffffffUL /* maximum unsigned long value */
I hope this helps,
Dave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|