本文介绍了下溢和浮点数学的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 一篇文章指出:在浮点数学中,如果你经常划分一个足够大的数字,那么你将永远能够获得到达a鉴于有限的精度,你可以得到的值太小而无法与零区分开来。 当一个值太小而无法与零区分时会发生什么? ; 以上分区?下溢? 这是什么意思足够频繁因为只有一个分区应该足够导致两个浮点数之间的分割下溢吗? 当发生下溢时,上述分区的结果应该是将 视为未定义的行为?换句话说,结果可以是任何浮动的 数字或只是无意义的数字。这是正确的吗? 感谢提前! 解决方案 No. 干杯 Michael - 电子邮件:我的是/ at / gmx / dot / de地址。 这取决于你所做的事情的性质。在某些情况下,它可能暗示你可能会丢失精确度或 爆炸的东西,但是...... 我不会一概而论,IMO ..你需要评估 结果是否符合你的期望,是否正确得到或者如果 下溢正在制造一团糟,你需要获得更高的精度 或以不同的方式执行计算。 我不知道任何硬性规定。 -Mysid 编号标准说明(第213页,7.12.1) 以lcc-win32编译器为例,我们有: 1)下溢被屏蔽并将近似为零。由于零 小于最小可表示数字,因此它符合 标准规格。 2)lcc-win32确实如此如果发生下溢,则不设置任何errno标志 3)如果用户在发生下溢之前用标准 函数fesetexceptionflag取消屏蔽下溢标志,则机器陷阱。 我希望这能说清楚。 jacob An article states: "In floating point maths, where if you divide by asufficiently large number sufficiently often, you will always be able toreach a value too small to distinguish from zero, given the finite precisionyou have."What happens when "a value too small to distinguish from zero" is reached bythe above division? Underflow?What does it mean "sufficiently often" since only one division should beenough to cause underflow in division between two floating point numbers?When underflow happens, the result of the above division should be regardedas "undefined behavior"? In other words, the result could be any floatingnumber or just a meanless "number." Is this correct?THANKS IN ADVANCE! 解决方案No.CheersMichael--E-Mail: Mine is an /at/ gmx /dot/ de address.It depends on the nature of what you are doing. In some case itcould be suggesting a possibility that you lost precision orsomething blew up, but...I wouldn''t generalize that, IMO.. you need to evaluate whether theresult fits your expectations and is the right thing to get or ifthe underflow is making a mess and you need to get a higher precisionor perform the computations differently.I don''t know of any hard and fast rule.-MysidNo. The standard says (page 213, 7.12.1)Taking the lcc-win32 compiler as an example we have:1) underflow is masked and will be approximated as zero. Since zerois less than the smallest representable number it is within thestandard specs.2) lcc-win32 does NOT set any errno flag if underflow occurs3) If the user unmasks the underflow flag with the standardfunction fesetexceptionflag before the underflow occurs, the machinewill trap at each underflow.I hope this makes this clear.jacob 这篇关于下溢和浮点数学的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-12 10:32