int float double 最大值,最小值

http://blog.csdn.net/zxy_snow/article/details/6123551

<limits>中没有double的最大最小值。。。

 

如果输出的比如%.100lf输出2.23432432,没有达到100位,则最后2后面不一定都是0。

 

原文见http://blog.csdn.net/ACb0y/archive/2010/03/01/5336822.aspx

 

[cpp]  view plain copy
  1. view plaincopy to clipboardprint?  
  2. /*   
  3.     coder: ACboy   
  4.     date: 2010-3-1   
  5. */   
  6.    
  7. #include <iostream>    
  8. #include <float.h>     
  9. using namespace std;     
  10.     
  11. int main()     
  12. {     
  13.     cout << "int 类型能存储的最大值和最小值" << endl;     
  14.     cout << "INT_MAX = " << INT_MAX << endl;     
  15.     cout << "INT_MIN = " << INT_MIN << endl;     
  16.     cout << "long 类型能存储的最大值和最小值" << endl;     
  17.     cout << "LONG_MAX = " << LONG_MAX << endl;     
  18.     cout << "LONG_MIN = " << LONG_MIN << endl;     
  19.     cout << "long long 类型能存储的最大值和最小值" << endl;     
  20.     cout << "LONG_LONG_MAX = " << LONG_LONG_MAX << endl;     
  21.     cout << "LONG_LONG_MIN = " << LONG_LONG_MIN << endl;     
  22.     cout << "float 类型能存储的最大值和最小值" << endl;     
  23.     cout << "FLT_MAX = " << FLT_MAX << endl;     
  24.     cout << "FLT_MIN = " << FLT_MIN << endl;     
  25.     cout << "double 类型能存储的最大值和最小值" << endl;     
  26.     cout << "DBL_MAX = " << DBL_MAX << endl;     
  27.     cout << "DBL_MIN = " << DBL_MIN << endl;     
  28.     return 0;     
  29. }    
 

 

从运行结果看:

int和long都是用32位来存储最大值和最小值分别为2147483647(109), -2147483648;

long long 是用64位来存储最大值和最小值分别为9223372036854775807(1018),-9223372036854775808;

float的最大值和最小值分别为3.40282e+038(1038),1.17549e-038(10-38);

double的最大值和最小值分别为1.79769e+308(10308),2.22507e-308(10-308)。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值