duanboshi1472 2017-12-19 18:21
浏览 27
已采纳

转换科学记数/指数[重复]

This question already has an answer here:

I am trying to convert a scientific notation/exponential number.

For example :

I get from a API request this number : 4.96E-6

I want to convert it to his normal value 0.00000496.

I searched on the web and tryed a few codes like

$awb = "4.96e-6"; // tried with and without quotes
$format = sprintf($awb, "%e");
var_dump($format);

it returns : string(7) "4.96E-6"

$awb = 4.96e-6;
$format = sscanf($awb, "%e");
var_dump($format);

Is returning :

array(1) { [0]=> float(4.96E-6) }

Please what should I do ?

Thank you

</div>
  • 写回答

1条回答 默认 最新

  • doupinge9055 2017-12-19 18:45
    关注

    You can use the number_format() function; e.g.

    <?php
    $awb = "4.96e-6";
    print number_format($awb, 10);
    ?>
    

    Will result in the output: 0.0000049600.

    See: http://php.net/manual/en/function.number-format.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于单片机数字电压表电路组成及框图
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line