What is gmp_root in PHP?
gmp_root is a function in PHP that returns the integer part of the nth root.
Syntax
gmp_root(GMP|int|string $num, int $Nth): GMP
Parameters
The function takes in two parameters: num and Nth.
-
num- can be a numericstring, object, or of typeGMP GNU Multiple Precision Arithmetic Library int. -
Nth- The positive root to take ofnum.
Return value
gmp_root returns the integer part of the Nth root. The value returned is type GMP number.
Code
<?php// gmp_init is used to create a GMP number$val1 = gmp_init("1001", 2);$num = 3;$val2 = gmp_root($val1, $num);echo gmp_strval($val2, 2);?>
Expected output
10