C ++:最大整数 [英] C++: max integer

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

问题描述

是否有一个C ++跨平台库为我提供了一个可移植的最大整数?

Is there a C++ cross-platform library that provides me with a portable maximum integer number?

我要声明:

const int MAX_NUM = /* call some library here */;

我使用MSVC 2008非托管。

I use MSVC 2008 unmanaged.

推荐答案

在C ++标准库标题< limits> 中,您将找到:

In the C++ standard library header <limits>, you will find:

std::numeric_limits<int>::max()

这将告诉你可以存储在 int 类型的变量中的最大值。 numeric_limits 是一个类模板,您可以传递任何数字类型,以获取它们可以容纳的最大值。

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.

numeric_limits 类模板中有很多其他有关数字类型的信息

这篇关于C ++:最大整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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