What's the C++ equivalent of UINT32_MAX?
Not sure about uint32_t
, but for fundamental types (bool
, char
, signed char
, unsigned char
, wchar_t
, short
, unsigned short
, int
, unsigned int
, long
, unsigned long
, float
, double
and long double
) you can use the numeric_limits
templates via #include <limits>
.
cout << "Minimum value for int: " << numeric_limits<int>::min() << endl;
cout << "Maximum value for int: " << numeric_limits<int>::max() << endl;
If uint32_t
is a #define
of one of the above than this code should work out of the box
cout << "Maximum value for uint32_t: " << numeric_limits<uint32_t>::max() << endl;
std::numeric_limits<T>::max()
defines the maximum value for type T
.
Well, uint32_t will always be 32 bit, and always be unsigned, so you can safely define it manually:
#define UINT32_MAX (0xffffffff)
You can also do
#define UINT32_MAX ((uint32_t)-1)