本文介绍了为int的最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有code找到C / C ++的整数(相应的编译器)的如 Integer.MaxValue
在Java函数的最大值?
Is there any code to find the maximum value of integer (accordingly to the compiler) in C/C++ like Integer.MaxValue
function in java?
推荐答案
在C ++:
#include <limits>
然后用
int imin = std::numeric_limits<int>::min(); // minimum value
int imax = std::numeric_limits<int>::max();
的std :: numeric_limits
是一个可以与其他类型的实例化一个模板类型:
std::numeric_limits
is a template type which can be instantiated with other types:
float fmin = std::numeric_limits<float>::min(); // minimum positive value
float fmax = std::numeric_limits<float>::max();
在C:
#include <limits.h>
然后用
int imin = INT_MIN; // minimum value
int imax = INT_MAX;
或
#include <float.h>
float fmin = FLT_MIN; // minimum positive value
double dmin = DBL_MIN; // minimum positive value
float fmax = FLT_MAX;
double dmax = DBL_MAX;
这篇关于为int的最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!