首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

double门类的取值范围

2012-09-06 
double类型的取值范围?查了一下C++中double类型的取值范围,但是有不同的结果,最大值确定是DBL_MAX,但是最

double类型的取值范围?
查了一下C++中double类型的取值范围,但是有不同的结果,最大值确定是DBL_MAX,但是最小值却有很多答案。比如DBL_MIN,-DBL_MAX,numeric_limits<double>::min(),而MSDN上说是范围是1.7E-308~1.7E308。
  其中DBL_MIN,numeric_limits<double>::min(),MSDN上最小值都是正数,最小值不应该是一个正数吧,我是想找有符号的double类型的最小值(即最小负数),大家知道吗?求指教.

[解决办法]
float.h

C/C++ code
...#define DBL_DIG         15                      /* # of decimal digits of precision */#define DBL_EPSILON     2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */#define DBL_MANT_DIG    53                      /* # of bits in mantissa */#define DBL_MAX         1.7976931348623158e+308 /* max value */#define DBL_MAX_10_EXP  308                     /* max decimal exponent */#define DBL_MAX_EXP     1024                    /* max binary exponent */#define DBL_MIN         2.2250738585072014e-308 /* min positive value */#define DBL_MIN_10_EXP  (-307)                  /* min decimal exponent */#define DBL_MIN_EXP     (-1021)                 /* min binary exponent */#define _DBL_RADIX      2                       /* exponent radix */#define _DBL_ROUNDS     1                       /* addition rounding: near */...
[解决办法]
C/C++ code
#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;}
[解决办法]
探讨

float.h
C/C++ code
...
#define DBL_DIG 15 /* # of decimal digits of precision */
#define DBL_EPSILON 2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON !……

热点排行