C/C++_int/float/double的最大值和最小值

WeThinkIn發表於2020-09-03
#include <iostream>
#include <float.h>
using namespace std;

int main()
{
	cout << "int 型別能儲存的最大值和最小值" << endl;
	cout << "INT_MAX = " << INT_MAX << endl;
	cout << "INT_MIN = " << INT_MIN << endl;
	cout << "long 型別能儲存的最大值和最小值" << endl;
	cout << "LONG_MAX = " << LONG_MAX << endl;
	cout << "LONG_MIN = " << LONG_MIN << endl;
	cout << "long long 型別能儲存的最大值和最小值" << endl;
	cout << "LONG_LONG_MAX = " << LONG_LONG_MAX << endl;
	cout << "LONG_LONG_MIN = " << LONG_LONG_MIN << endl;
	cout << "float 型別能儲存的最大值和最小值" << endl;
	cout << "FLT_MAX = " << FLT_MAX << endl;
	cout << "FLT_MIN = " << FLT_MIN << endl;
	cout << "double 型別能儲存的最大值和最小值" << endl;
	cout << "DBL_MAX = " << DBL_MAX << endl;
	cout << "DBL_MIN = " << DBL_MIN << endl;
	return 0;
}

-----------結果如下---------------

int 型別能儲存的最大值和最小值
INT_MAX = 2147483647
INT_MIN = -2147483648
long 型別能儲存的最大值和最小值
LONG_MAX = 9223372036854775807
LONG_MIN = -9223372036854775808
long long 型別能儲存的最大值和最小值
LONG_LONG_MAX = 9223372036854775807
LONG_LONG_MIN = -9223372036854775808
float 型別能儲存的最大值和最小值
FLT_MAX = 3.40282e+38
FLT_MIN = 1.17549e-38
double 型別能儲存的最大值和最小值
DBL_MAX = 1.79769e+308
DBL_MIN = 2.22507e-308

相關文章