Is there a C++ cross-platform library that provides me with a portable maximum integer number?
I want to declare:
const int MAX_NUM = /* call some library here */;
I use MSVC 2008 unmanaged.
In the C++ standard library header <limits>
, you will find:
std::numeric_limits<int>::max()
Which will tell you the maximum value that can be stored in a variable of type int
. numeric_limits
is a class template, and you can pass it any of the numeric types to get the maximum value that they can hold.
The numeric_limits
class template has a lot of other information about numeric types as well.
See limits.h
(C) or climits
(C++). In this case you would want the INT_MAX
constant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With