什么是C ++等效的UINT32_MAX? [英] What's the C++ equivalent of UINT32_MAX?

查看:2932
本文介绍了什么是C ++等效的UINT32_MAX?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C99中,我包括stdint.h,它给了UINT32_MAX以及uint32_t。然而,在C ++中UINT32_MAX被定义出来。我可以在包含stdint.h之前定义__STDC_LIMIT_MACROS,但是如果有人在包括stdint.h本身之后包含我的头部,那么它不起作用。

In C99, I include stdint.h and that gives me UINT32_MAX as well as uint32_t. However, in C++ the UINT32_MAX gets defined out. I can define __STDC_LIMIT_MACROS before including stdint.h, but this doesn't work if someone is including my header after already including stdint.h themselves.

在C ++中,找到uint32_t中可表示的最大值的标准方法

So in C++, what's the standard way of finding out the maximum value representable in a uint32_t?

推荐答案

$ c> uint32_t 但是对于基本类型( bool,char,signed char,unsigned char,wchar_t,short,unsigned short,int,unsigned int,long,unsigned long, float,double和long double ),您应该使用 numeric_limits 模板通过 #include< limits>

Well, I don't know about uint32_t but for the 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 should 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;

如果 uint32_t 是<$ c $

    cout << "Maximum value for uint32_t: " << numeric_limits<uint32_t>::max() << endl;

这篇关于什么是C ++等效的UINT32_MAX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆