本文介绍了为什么在这个C代码中使用的IEEE-754指数偏差是126.94269504,而不是127?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 以下C函数来自 fastapprox 项目。 static inline float fasterlog2(float x) { union {float f;我uint32_t我; } vx = {x}; float y = vx.i; y * = 1.1920928955078125e-7f; return y - 126.94269504f; 这里有些专家可以解释为什么上面代码中使用的指数偏差是126.94269504而不是127?它是更准确的偏差值吗?解决方案在你链接的项目中,他们包括一个 Mathematica笔记本,其中包含mysterious的算法解释。 126.94269 值。 如果您需要查看器,您可以从 Mathematica网站免费。 编辑:由于我感觉很慷慨,一个href =https://i.imgur.com/DhULOgu.png =noreferrer>截图形式。简单的说,他们解释说,价值是更简单,更快,更不准确。 他们没有使用 -126.94269 来代替 -127 ,他们正在使用它来代替下面的计算结果(为简洁起见,取整的值): -124.2255 - 1.498 * mx - (1.72588 /(0.35201 + mx)) The following C function is from fastapprox project.static inline floatfasterlog2 (float x){ union { float f; uint32_t i; } vx = { x }; float y = vx.i; y *= 1.1920928955078125e-7f; return y - 126.94269504f;}Could some experts here explain why the exponent bias used in the above code is 126.94269504 instead of 127? Is it more accurate bias value? 解决方案 In the project you linked, they included a Mathematica notebook with an explanation of their algorithms, which includes the "mysterious" -126.94269 value.If you need a viewer, you can get one from the Mathematica website for free.Edit: Since I'm feeling generous, here's the relevant section in screenshot form.Simply put, they explain that the value is "simpler, faster, and less accurate".They're not using -126.94269 in place of -127, they're using it in place of the result of the following calculation (values rounded for brevity):-124.2255 - 1.498 * mx - (1.72588 / (0.35201 + mx)) 这篇关于为什么在这个C代码中使用的IEEE-754指数偏差是126.94269504,而不是127?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-08 03:22