Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

gmp_rootrem

Description

The gmp_rootrem of GMP for PHP takes the integer part and remainder of nth root.

Syntax

gmp_rootrem(
    GMP|int|string $num,
    int $nth
): array

Parameters

num

A GMP object, an int or a numeric string.

nth

The positive root to take of num.

Return

Returns a two element array, where the first element is the integer component of the root, and the second element is the remainder, both represented as GMP numbers.

Examples

1 · num · GMP · nth

<?

$num = 28;
$nth = 3;

$num = gmp_init($num);

$return = gmp_rootrem($num, $nth);

var_dump($return);
array(2) {
  [0]=>
  object(GMP)#2 (1) {
    ["num"]=>
    string(1) "3"
  }
  [1]=>
  object(GMP)#3 (1) {
    ["num"]=>
    string(1) "1"
  }
}

2 · num · int · nth

<?

$num = 28;
$nth = 3;

$return = gmp_rootrem($num, $nth);

var_dump($return);
array(2) {
  [0]=>
  object(GMP)#1 (1) {
    ["num"]=>
    string(1) "3"
  }
  [1]=>
  object(GMP)#2 (1) {
    ["num"]=>
    string(1) "1"
  }
}

3 · num · string · nth

<?

$num = "28";
$nth = 3;

$return = gmp_rootrem($num, $nth);

var_dump($return);
array(2) {
  [0]=>
  object(GMP)#1 (1) {
    ["num"]=>
    string(1) "3"
  }
  [1]=>
  object(GMP)#2 (1) {
    ["num"]=>
    string(1) "1"
  }
}
HomeMenu