前进的道路不是一帆风顺的,要随时迎接挑战,敢于战胜困难!

坚持一下,找人聊聊天,释放一些压力!

 

C常用类型的范围--源代码

 

 

#include <iostream>
#include <limits>
#include <stdlib.h>

using namespace std;
typedef unsigned __int64 UINT64;
typedef __int64 INT64;

int main()
{
int intMax = numeric_limits<int>::max();
int intMin = numeric_limits<int>::min();
long longMax=numeric_limits<long>::max();
long longMin=numeric_limits<long>::min();
//float floatMax=numeric_limits<float>::max();
//float floatMin=numeric_limits<float>::min();
unsigned long uint32Max=numeric_limits<unsigned long>::max();
unsigned long uint32Min=numeric_limits<unsigned long>::min();
//__int64 int64Max=numeric_limits<__int64>::max();
//__int64 int64Min=numeric_limits<__int64>::min();
//unsigned __int64 uint64Max=numeric_limits<unsigned __int64>::max();
//unsigned __int64 uint64Min=numeric_limits<unsigned __int64>::min();

UINT64 uint64Max;
uint64Max=(1<<(sizeof(UINT64)*8)); //我觉得这么写比写64更恰当
uint64Max-=1;
printf("uint64Max:  %I64u\n",uint64Max); //注意输出是%I64u //我尝试重载<<并用cout输出,但是失败了

float floatMax = numeric_limits<float>::max();
float floatMin = numeric_limits<float>::min();

//cout << floatMax << " " << floatMin << endl;
cout <<"longMax: "<< longMax << "   longMin" << longMin << endl;
cout <<"intMax:  "<< intMax << "    intMin" << intMin << endl;
cout <<"floatMax "<< floatMax << "  floatMin" << floatMin << endl;
cout <<"uint32Max: "<< uint32Max << "   uint32Min" << uint32Min << endl;
//cout <<"int64Max: "<< _I64_MAX << "   int64Min" << _I64_MIN << endl;
printf("int64Max: %I64d  int64Min: %I64d\n", _I64_MAX, _I64_MIN);
printf("uint64Max: %I64u  uint64Min: 0\n", _UI64_MAX);
//cout <<"uint64Max: "<< uint64Max << "   uint64Min" << uint64Min << endl;

system("pause");

return 0;
}

 

posted on 2009-06-09 14:30  山径山精  阅读(477)  评论(0编辑  收藏  举报

导航