Large numbers in PHP are not what they seem to be

前端 未结 3 1585
独厮守ぢ
独厮守ぢ 2021-01-27 20:07

I agree with this

php > var_dump(number_format(10000000000000000000000)); // 10^22
php shell code:1:
string(30) \"10,000,000,000,000,000,000,000\"
         


        
3条回答
  •  别那么骄傲
    2021-01-27 20:35

    Floating point numbers.

    Computer memory is limited, so storing an infinitely precise integer value is impossible. Your system basically ran out of room for precise integer valuation.

    This answer does a great job talking about how to get the integer to appear at the number you want it though.

提交回复
热议问题