Display float value w/o scientific notation

后端 未结 4 505
长发绾君心
长发绾君心 2020-11-27 20:00

When i make the following multiplication in PHP:

$ret = 1.0 * 0.000000001;

i get the result: 1.0E-9

I want to convert this result i

4条回答
  •  盖世英雄少女心
    2020-11-27 20:58

    I suggest the use BCMath for more accuracy when you are calculating with decimal numbers. That makes sure that you actually get the results you want.

    To print what you want, you should specify the precision and use %.9f, since it defaults to displaying 6 decimal numbers. That makes it something like this (just like bsdnoobz already said):

    sprintf('%.9f',$ret);
    

提交回复
热议问题