<small id='Crxa6'></small><noframes id='Crxa6'>

    1. <i id='Crxa6'><tr id='Crxa6'><dt id='Crxa6'><q id='Crxa6'><span id='Crxa6'><b id='Crxa6'><form id='Crxa6'><ins id='Crxa6'></ins><ul id='Crxa6'></ul><sub id='Crxa6'></sub></form><legend id='Crxa6'></legend><bdo id='Crxa6'><pre id='Crxa6'><center id='Crxa6'></center></pre></bdo></b><th id='Crxa6'></th></span></q></dt></tr></i><div id='Crxa6'><tfoot id='Crxa6'></tfoot><dl id='Crxa6'><fieldset id='Crxa6'></fieldset></dl></div>

      1. <tfoot id='Crxa6'></tfoot>

        • <bdo id='Crxa6'></bdo><ul id='Crxa6'></ul>
        <legend id='Crxa6'><style id='Crxa6'><dir id='Crxa6'><q id='Crxa6'></q></dir></style></legend>
      2. 如何加速浮点到整数的转换?

        时间:2023-09-16

              <tbody id='iiQGF'></tbody>
                <legend id='iiQGF'><style id='iiQGF'><dir id='iiQGF'><q id='iiQGF'></q></dir></style></legend>

                <i id='iiQGF'><tr id='iiQGF'><dt id='iiQGF'><q id='iiQGF'><span id='iiQGF'><b id='iiQGF'><form id='iiQGF'><ins id='iiQGF'></ins><ul id='iiQGF'></ul><sub id='iiQGF'></sub></form><legend id='iiQGF'></legend><bdo id='iiQGF'><pre id='iiQGF'><center id='iiQGF'></center></pre></bdo></b><th id='iiQGF'></th></span></q></dt></tr></i><div id='iiQGF'><tfoot id='iiQGF'></tfoot><dl id='iiQGF'><fieldset id='iiQGF'></fieldset></dl></div>
                <tfoot id='iiQGF'></tfoot>
                  <bdo id='iiQGF'></bdo><ul id='iiQGF'></ul>

                  <small id='iiQGF'></small><noframes id='iiQGF'>

                  本文介绍了如何加速浮点到整数的转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我们在项目中进行了大量的浮点到整数转换.基本上是这样的

                  We're doing a great deal of floating-point to integer number conversions in our project. Basically, something like this

                  for(int i = 0; i < HUGE_NUMBER; i++)
                       int_array[i] = float_array[i];
                  

                  执行转换的默认 C 函数非常耗时.

                  The default C function which performs the conversion turns out to be quite time consuming.

                  是否有任何解决方法(可能是手动调整功能)可以稍微加快进程?我们不太关心精度.

                  Is there any work around (maybe a hand tuned function) which can speed up the process a little bit? We don't care much about a precision.

                  推荐答案

                  这里的大多数其他答案只是试图消除循环开销.

                  Most of the other answers here just try to eliminate loop overhead.

                  只有 deft_code 的答案 触及了真正问题的核心——将浮点数转换为整数是在 x86 处理器上价格高得惊人.deft_code 的解决方案是正确的,尽管他没有给出引用或解释.

                  Only deft_code's answer gets to the heart of what is likely the real problem -- that converting floating point to integers is shockingly expensive on an x86 processor. deft_code's solution is correct, though he gives no citation or explanation.

                  这里是技巧的来源,有一些解释以及特定于您是要向上、向下还是向零舍入的版本:了解您的 FPU

                  Here is the source of the trick, with some explanation and also versions specific to whether you want to round up, down, or toward zero: Know your FPU

                  很抱歉提供一个链接,但实际上这里写的任何内容,除了复制那篇出色的文章,都不会使事情变得清晰.

                  Sorry to provide a link, but really anything written here, short of reproducing that excellent article, is not going to make things clear.

                  这篇关于如何加速浮点到整数的转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如果我们已经有了 RVO,移动语义会提供什么优化 下一篇:便携式分支预测提示

                  相关文章

                  最新文章

                  <tfoot id='sNYwy'></tfoot>
                • <legend id='sNYwy'><style id='sNYwy'><dir id='sNYwy'><q id='sNYwy'></q></dir></style></legend>
                    <bdo id='sNYwy'></bdo><ul id='sNYwy'></ul>
                • <i id='sNYwy'><tr id='sNYwy'><dt id='sNYwy'><q id='sNYwy'><span id='sNYwy'><b id='sNYwy'><form id='sNYwy'><ins id='sNYwy'></ins><ul id='sNYwy'></ul><sub id='sNYwy'></sub></form><legend id='sNYwy'></legend><bdo id='sNYwy'><pre id='sNYwy'><center id='sNYwy'></center></pre></bdo></b><th id='sNYwy'></th></span></q></dt></tr></i><div id='sNYwy'><tfoot id='sNYwy'></tfoot><dl id='sNYwy'><fieldset id='sNYwy'></fieldset></dl></div>

                    <small id='sNYwy'></small><noframes id='sNYwy'>