What's the C++ equivalent of UINT32_MAX?

前端 未结 5 1751
广开言路
广开言路 2021-02-02 07:27

In C99, I include stdint.h and that gives me UINT32_MAX as well as uint32_t data type. However, in C++ the UINT32_MAX gets d

5条回答
  •  逝去的感伤
    2021-02-02 07:44

    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 .

    cout << "Minimum value for int: " << numeric_limits::min() << endl;
    cout << "Maximum value for int: " << numeric_limits::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::max() << endl;
    

提交回复
热议问题