Home > Backend Development > PHP Tutorial > php double作减法

php double作减法

WBOY
Release: 2016-06-13 13:18:14
Original
903 people have browsed it

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>
Copy after login
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