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

c – std :: numeric_limits :: epsilon()用于积分,第1张

概述我没有关于std :: numeric_limits< T>的任何好的参考,但网上的网站说std :: numeric_limits< T> :: epsilon()将返回1和它之后的最小数字之间的差值.据我所知的int类型,1之后的下一个数字是2,所以epsilon应该是1.但它是0( Linux,g 4.4.5).这背后的原因是什么? 我知道在实践中epsilon()仅对浮点类型有用,我只是在 我没有关于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作为其不是有意义值的指示.

总结

以上是内存溢出为你收集整理的c – std :: numeric_limits :: epsilon()用于积分全部内容,希望文章能够帮你解决c – std :: numeric_limits :: epsilon()用于积分所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1255632.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-07
下一篇2022-06-07

发表评论

登录后才能评论

评论列表(0条)

    保存