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

WBOY
Release: 2016-06-13 11:50:06
Original
1296 people have browsed it

高手开过来!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 />
Copy after login

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!