首页 > 解决方案 > PHP GMP:POW,exp 必须是浮点数

问题描述

尝试使用 PHP GMP 模块计算一些非常大的数字。到目前为止一切都很好,直到我不得不使用 GMP_POW,但 EXP 必须是浮点数,而不是数字或字符串。

适用于小数字的简单方法:

$result = pow(25323532325, 0.95); // Output: 7644482136.6877

但是使用 GMP:

$result = gmp_pow(25323532325, "0.95"); // Output: 1 

我不那么聪明的想法:

$result = gmp_pow(gmp_init(25323532325), gmp_init(0.95)); // Error: Unable to convert variable to GMP - string is not an integer

标签: phpgmp

解决方案


推荐阅读