DBL_MIN是最小的正整数倍吗? [英] Is DBL_MIN the smallest positive double?

查看:1302
本文介绍了DBL_MIN是最小的正整数倍吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问::DBL_MIN是最小的正整数吗?

Q: Is DBL_MIN the smallest positive double?

下面的代码似乎可以解决这个问题.但是,如果这是真的,那么DBL_MIN是如何定义的,其用途或目的是什么.

The code below seems to anwser this question with no. But if this is true, how is DBL_MIN the defined and what is its use or purpose.

平台:Windows7& Visual Studio 2013

Platform: Windows7 & Visual Studio 2013

double next_to_zero = std::nextafter(0.0,DBL_MIN);
bool b =  DBL_MIN <= next_to_zero;
std::cout << std::boolalpha 
          << "is dbl_min the smallest representable double? "
          << b << '\n';

std::cout << std::setprecision(56)
          << "dbl_min = " << DBL_MIN << '\n'
          << "next to zero = " << next_to_zero;

输出:

dbl_min是最小的可表示双精度数吗?错误

is dbl_min the smallest representable double? false

dbl_min = 2.2250738585072013830902327173324040642192159804623318306e-308

dbl_min = 2.2250738585072013830902327173324040642192159804623318306e-308

紧邻零= 4.9406564584124654417656879286822137236505980261432476443e-324

next to zero = 4.9406564584124654417656879286822137236505980261432476443e-324

推荐答案

我可能不必要地将这个答案限制为IEEE754浮点数.

I'm restricting this answer, perhaps unnecessarily, to IEEE754 floating point.

DBL_MIN不允许为次正规编号.

但是std::nextafter允许返回 subnormal 编号.

因此,后者的返回值可能小于DBL_MIN.

Hence the return value of the latter could be less than DBL_MIN.

有关更多详细信息,请参见 https://en.wikipedia.org/wiki/Denormal_number

For more details see https://en.wikipedia.org/wiki/Denormal_number

这篇关于DBL_MIN是最小的正整数倍吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆