<bdo id='eWA2i'></bdo><ul id='eWA2i'></ul>

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

      <tfoot id='eWA2i'></tfoot>

      <legend id='eWA2i'><style id='eWA2i'><dir id='eWA2i'><q id='eWA2i'></q></dir></style></legend>
      1. 显示不带科学计数法的浮点值

        Display float value w/o scientific notation(显示不带科学计数法的浮点值)

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

              <tfoot id='07F1W'></tfoot>

                <small id='07F1W'></small><noframes id='07F1W'>

                  本文介绍了显示不带科学计数法的浮点值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我在 PHP 中进行以下乘法运算时:

                  When i make the following multiplication in PHP:

                  $ret = 1.0 * 0.000000001;
                  

                  我得到结果:1.0E-9

                  i get the result: 1.0E-9

                  我想把这个结果转换成普通的十进制符号,我该怎么做?

                  I want to convert this result into the normal decimal notation, how can i do this?

                  sprintf('%f',$ret) 不起作用,它返回 0.000000.溢出?

                  sprintf('%f',$ret) doesn't work, it returns 0.000000. Overflow?

                  推荐答案

                  sprintf('%f',$ret) 不起作用,它返回 0.000000.溢出?

                  sprintf('%f',$ret) doesn't work, it returns 0.000000. Overflow?

                  sprintf 有效,但是您在这里错过了一些要点.

                  sprintf works, however you miss some point here.

                  0.000000 没有溢出.只是 %f 修饰符的 sprintf 默认使用 6 位数字.另外请注意 %f 可以识别区域设置,%F 可能更适合.

                  0.000000 is not overflow. It's just that sprintf for the %f modifier uses 6 digits per default. Also please take care that %f is locale aware, %F is probably better suited.

                  您可能想要使用更多数字,例如假设是 4 000 000(四百万):

                  You might want to use more digits, e.g. let's say 4 000 000 (four million):

                  $ php -r "printf('%.4000000F', 1*0.000000001);"
                  
                  Notice: printf(): Requested precision of 4000000 digits was truncated to PHP maximum of 53 digits in Command line code on line 1
                  
                  Call Stack:
                      0.0001     319080   1. {main}() Command line code:0
                      0.0001     319200   2. printf() Command line code:1
                  
                  0.00000000100000000000000006228159145777985641889706869
                  

                  如本例所示,不仅有一个公共值(6 位),还有一个最大值(可能取决于 PHP 执行的计算机系统),在我的例子中,如警告所示,这里截断为 53 位.

                  As this example shows, there is not only a common value (6 digits) but also a maximum (probably depended on the computer system PHP executes on), here truncated to 53 digits in my case as the warning shows.

                  因为你的问题,我想说你想展示:

                  Because of your question I'd say you want to display:

                  0.000000001
                  

                  这是九位数字,所以你需要这样写:

                  Which are nine digits, so you need to write it that way:

                  sprintf('%.9F',$ret)
                  

                  但是,您可能想要这样做:

                  However, you might want to do this:

                  rtrim(sprintf('%.20F', $ret), '0');
                  

                  之后会从右边删除零:

                  0.000000001
                  

                  希望这有帮助.

                  这篇关于显示不带科学计数法的浮点值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

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

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

                            <bdo id='Y4A1N'></bdo><ul id='Y4A1N'></ul>
                          • <tfoot id='Y4A1N'></tfoot>