php乘法有bug?解决办法

WBOY
Release: 2016-06-13 13:35:25
Original
983 people have browsed it

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

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

PHP code
echo bcadd(bcmul(85112854, 4294967296), 384440042); 
------解决方案--------------------
echo bcadd(bcmul('85112854', '4294967296', 0), '384440042', 0);//365556924783662826
Copy after login
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
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!