PHP - gmp_rootrem() 函式



定義和用法

gmp_rootrem() 函式返回 n 次方根的整數部分和餘數。

描述

gmp_rootrem() 計算給定數字的 n 次方根,並返回整數部分和餘數。

語法

gmp_rootrem ( GMP $a , int $nth ) : array
序號 引數 描述
1

a

可以是 GMP 資源數字、gmp 物件或數字字串。

2

nth

對數字 a 進行開方的正根。

返回值

PHP gmp_rootrem() 函式返回一個數組,第一個元素是整數部分,第二個元素是餘數。

PHP 版本

此函式可在高於 5.6.0 的 PHP 版本中使用。

示例 1

gmp_root 的工作方式 -

<?php
   $num = gmp_rootrem('150', 2);
   echo "The integer value is : ".$num[0]." and remainder is : ".$num[1];
?>

這將產生以下結果 -

The integer value is : 12 and remainder is : 6

示例 2

gmp_root() 的工作方式 -

<?php
	c$num = gmp_rootrem('2685', 3);
	echo "The integer value is : ".$num[0]." and cremainder is : ".$num[1];
?>

這將產生以下結果 -

The integer value is : 13 and remainder is : 488
php_function_reference.htm
廣告