PHP加法(+)函数是否有限制?

时间:2019-10-06 08:53:51

标签: php

我认为我在PHP中有点局限性。

有人可以解决这个问题吗?

$num1=pow(2,500);
#Works. Output:
3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376

$num2=pow(2,565);
#Works. Output:
36893488147419103232

$num3=$num1+$num2;
# No error, but the output is incorrect. It is simply the value of "num1".
3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376

它认为浮动不是问题。因为我可以这样做:

$zahl3=$zahl1*2;
#Output:
6546781215792283740026379393655198304433284092086129578966582736192267592809349109766540184651808314301773368255120142018434513091770786106657055178752

# But I cannot do something like this: 
$zahl3=$zahl1+10; ``` 

Maybe a problem with the vars and the space?

1 个答案:

答案 0 :(得分:1)

也许与float的最大值有关

来自https://www.php.net/manual/en/language.types.float.php

  

浮点数的大小取决于平台,尽管通常值(64位IEEE格式)的最大值约为1.8e308,精度约为14个十进制数字。

相关问题