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

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

    2. <legend id='fDI3D'><style id='fDI3D'><dir id='fDI3D'><q id='fDI3D'></q></dir></style></legend>

      PHP 类型转换 float->int

      时间:2023-07-15

        <bdo id='B7dmQ'></bdo><ul id='B7dmQ'></ul>
        <legend id='B7dmQ'><style id='B7dmQ'><dir id='B7dmQ'><q id='B7dmQ'></q></dir></style></legend>

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

          2. <tfoot id='B7dmQ'></tfoot>

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

              <tbody id='B7dmQ'></tbody>

              1. 本文介绍了PHP 类型转换 float->int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                鉴于此 PHP 代码:

                Given this PHP code:

                // total is 71.24 (float)
                $value = $total * 100;
                var_dump($value);
                $valuecast = (int)$value;
                var_dump($valuecast);
                settype($value, 'int');
                var_dump($value);
                

                var_dump($value) 给出 float(7124)

                var_dump($value) gives float(7124)

                var_dump($valuecast) 给出 int(7123)

                var_dump($valuecast) gives int(7123)

                var_dump($value) 后 settype 给出 int(7123)

                var_dump($value) after settype gives int(7123)

                如何获得正确的类型转换?

                How can I get the correct type conversion?

                推荐答案

                对于 float 到 int,我建议 round.这是为了迎合 IEEE 浮点不精确.

                For float to int, I'd suggest round. This is to cater to IEEE float imprecision.

                这篇关于PHP 类型转换 float->int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:类型转换与函数在 PHP 中转换变量类型 下一篇:从 SimpleXMLObject 到数组的递归转换

                相关文章

                  • <bdo id='L6h0H'></bdo><ul id='L6h0H'></ul>

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