C++优雅之旅

探索C++

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  15 随笔 :: 0 文章 :: 20 评论 :: 0 Trackbacks
      在C++中,要想得到数值类型的最大最小值(有符号)可以包含<limits>头文件,使用numeric_limits<type>模板类:
#include <iostream>
#include 
<limits>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    cout 
<< numeric_limits<int>::min() << endl;
    cout 
<< numeric_limits<int>::max() << endl;

    cout 
<< numeric_limits<double>::min() << endl;
    cout 
<< numeric_limits<double>::max() << endl;

    
return 0;
}

      上例分别输出int型和double型值的最小值和最大值。
posted on 2008-04-28 23:26 林公子 阅读(4017) 评论(0)  编辑 收藏 引用 所属分类: C++/CLI

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理