开发者

PHP integer exponentiation (super large numbers)

开发者 https://www.devze.com 2022-12-10 07:04 出处:网络
Using PHP I want开发者_如何学Go to do millions of 2^n exponentiation but so far I only got up to n^1023 before PHP printed INF.

Using PHP I want开发者_如何学Go to do millions of 2^n exponentiation but so far I only got up to n^1023 before PHP printed INF.

Any ideas?


As Greg said, BC Math is fine, but if you really need efficiency, try GMP instead.


You can use the BC Math functions:

  $num = bcpow(2, 1000000); // Takes a few seconds to run!
0

精彩评论

暂无评论...
验证码 换一张
取 消