Home >Backend Development >PHP Tutorial > php乘法有bug?解决办法

php乘法有bug?解决办法

WBOY
WBOYOriginal
2016-06-13 13:35:251054browse

php乘法有bug?
85112854 * 4294967296 + 384440042 
计算结果用sprintf("%.0f"输出是365556924783662848,而用计算器计算得到的结果是365556924783662826
被这个问题搞的头大死了。。
有谁知道是什么原因吗?

------解决方案--------------------
这样运算,或用gmp函数

PHP code

echo    bcadd(bcmul(85112854, 4294967296), 384440042);
<br><font color="#e78608">------解决方案--------------------</font><br>
echo bcadd(bcmul('85112854', '4294967296', 0), '384440042', 0);//365556924783662826<br> <div class="clear">
                 
              
              
        
            </div>
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