Home  >  Article  >  Backend Development  >  高手开过来!PHP的bcmath有关问题你懂吗

高手开过来!PHP的bcmath有关问题你懂吗

WBOY
WBOYOriginal
2016-06-13 11:50:061298browse

高手开过来!PHP的bcmath问题你懂吗?

<br />$b=0.000000011;<br />$post=100000000;<br />$aa=strval($b);<br />$pos=strval($post);<br />echo bcmul($aa,$pos,10);<br />echo '<br/>';<br />$aa="0.000000011";<br />$pos="100000000";<br />echo bcmul($aa,$pos,10);<br />

结果是:
0
1.100000000
为什么?强制转换跟直接赋值不一样?
------解决方案--------------------
$b=0.000000011;<br />$aa=strval($b);<br />var_dump($aa);

输出的结果是 string '1.1E-8' (length=6)
和 '0.000000011'是不一样的
------解决方案--------------------
科学计数法不是高精度计数法
所以 bcmath 不支持科学计数法
$b=0.000000011;
echo strval($b); //1.1E-8

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn