Is there any macro in C or C++ represent the max and min value of int32_t and int64_t? I know it can be literally defined by oneself, but it's better if there is a standard macro. Please note I'm not asking about max of int, long ,etc. but intXX_t
In C++, there is std::numeric_limits::min() and std::numeric_limits::max() in the <limits> header:
std::cout << std::numeric_limits<std::int32_t>::min() << std::endl;
and so on. In C, the header <stdint.h> defines INT32_MIN, INT32_MAX etc. These are also available in the C++ <cstdint> header.
In C++ you can use header <limits> and class std::numeric_limts declared in this header.
To know the max and min values of types int32_t and int64_t you can write for example
#include <cstdint>
#include <limits>
//...
std::cout << std::numeric_limits<int32_t>::max() << std::endl;
std::cout << std::numeric_limits<int32_t>::min() << std::endl;
std::cout << std::numeric_limits<int64_t>::max() << std::endl;
std::cout << std::numeric_limits<int64_t>::min() << std::endl;
In C you should include header <stdint.h> and use corresponding macros defined in the header as for example
INT32_MIN
INT32_MAX
INT64_MIN
INT64_MAX
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