加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – std :: numeric_limits :: epsilon()用于积分

发布时间:2020-12-16 03:25:37 所属栏目:百科 来源:网络整理
导读:我没有关于std :: numeric_limits T的任何好的参考,但网上的网站说std :: numeric_limits T :: epsilon()将返回1和它之后的最小数字之间的差值.据我所知的int类型,1之后的下一个数字是2,所以epsilon应该是1.但它是0( Linux,g 4.4.5).这背后的原因是什么? 我
我没有关于std :: numeric_limits< T>的任何好的参考,但网上的网站说std :: numeric_limits< T> :: epsilon()将返回1和它之后的最小数字之间的差值.据我所知的int类型,1之后的下一个数字是2,所以epsilon应该是1.但它是0( Linux,g 4.4.5).这背后的原因是什么?

我知道在实践中epsilon()仅对浮点类型有用,我只是在挑剔.

解决方法

标准说([numeric.limits.members])

Meaningful for all floating point types.

该标准还说([numeric.special])

many values are only required to be meaningful under certain conditions (for example,epsilon() is only meaningful if is_integer is false). Any value that is not “meaningful” shall be set to 0 or false.

由于该值不是“有意义的”,因此标准需要值0作为其不是有意义值的指示.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读