Home  >  Article  >  Backend Development  >  php double作减法

php double作减法

WBOY
WBOYOriginal
2016-06-13 13:18:14862browse

php double做减法
我有一个变量$temp=42540528736698570378174246518995812352,gettype得到的类型是float,我想把它减1,但是使用$temp-1或者$temp-1=得到的值居然还是42540528736698570378174246518995812352。
怎么才能得到正确的值啊

------解决方案--------------------
我的天啦。我看眼花了。为什么不用string类型?
------解决方案--------------------
float有这么大么...

用gmp/bc处理大数。
------解决方案--------------------

PHP code
$dec_end = '42540528736698570378174246518995812352';
echo gmp_strval(gmp_sub(strval($dec_end),"1")); <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
Previous article: 网站总是被黑 Next article: as3与php交互兑现总结