入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

C/C++中各种类型int、long long、double表示范围(最大最小值)

创建时间:2015-05-10 投稿人: 浏览次数:5397
#include<iostream>
#include<string>
#include <limits>
using namespace std;
int main()
{
    cout << "type: 			" << "************size**************"<< endl;
    cout << "short: 			" << "字节数:" << sizeof(short) <<endl;
    cout << "最大值:" << (numeric_limits<short>::max)();
    cout << "		最小值:" << (numeric_limits<short>::min)() << endl;
    cout << "int: 			" << "字节数:" << sizeof(int) <<endl;
    cout << "最大值:" << (numeric_limits<int>::max)();
    cout << "	最小值:" << (numeric_limits<int>::min)() << endl;
    cout << "unsigned: 		" << "字节数:" << sizeof(unsigned) <<endl;
    cout << "最大值:" << (numeric_limits<unsigned>::max)();
    cout << "	最小值:" << (numeric_limits<unsigned>::min)() << endl;
    cout << "long: 			" << "字节数:" << sizeof(long) <<endl;
    cout << "最大值:" << (numeric_limits<long>::max)();
    cout << "	最小值:" << (numeric_limits<long>::min)() << endl;
    cout << "unsigned long: 		" << "字节数:" << sizeof(unsigned long) <<endl;
    cout << "最大值:" << (numeric_limits<unsigned long>::max)();
    cout << "	最小值:" << (numeric_limits<unsigned long>::min)() << endl;
	cout << "long long: 		" << "字节数:" << sizeof(long long) <<endl;
    cout << "最大值:" << (numeric_limits<long long>::max)();
    cout << "		最小值:" << (numeric_limits<long long>::min)() << endl;
	cout << "unsigned long long: 	" << "字节数:" << sizeof(unsigned long long) <<endl;
    cout << "最大值:" << (numeric_limits<unsigned long long>::max)();
    cout << "		最小值:" << (numeric_limits<unsigned long long>::min)() << endl;
    cout << "double: 		" << "字节数:" << sizeof(double) <<endl;
    cout << "最大值:" << (numeric_limits<double>::max)();
    cout << "	最小值:" << (numeric_limits<double>::min)() << endl;
    cout << "long double: 		" << "字节数:" << sizeof(long double) <<endl;
    cout << "最大值:" << (numeric_limits<long double>::max)();
    cout << "	最小值:" << (numeric_limits<long double>::min)() << endl;
    cout << "float: 			" << "字节数:" << sizeof(float) <<endl;
    cout << "最大值:" << (numeric_limits<float>::max)();
    cout << "	最小值:" << (numeric_limits<float>::min)() << endl;
    return 0;
}



声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
  • 上一篇:没有了
  • 下一篇:没有了
未上传头像