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

gmp_invert

Description

The gmp_invert of GMP for PHP inverses by modulo.

Syntax

gmp_invert(
    GMP|int|string $num1,
    GMP|int|string $num2
): GMP|false

Parameters

num1

A GMP object, an int or a numeric string.

num2

A GMP object, an int or a numeric string.

Return

Returns a GMP number on success or false if an inverse does not exist.

Examples

1 · num1 num2 · GMP

<?

$num1 = 2;
$num2 = 3;

$num1 = gmp_init($num1);
$num2 = gmp_init($num2);

$return = gmp_invert($num1, $num2);

var_dump($return);

?>
object(GMP)#3 (1) {
  ["num"]=>
  string(1) "2"
}

2 · num1 num2 · int

<?

$num1 = 2;
$num2 = 3;

$return = gmp_invert($num1, $num2);

var_dump($return);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "2"
}

3 · num1 num2 · string

<?

$num1 = "2";
$num2 = "3";

$return = gmp_invert($num1, $num2);

var_dump($return);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "2"
}

4 · inverse does not exist

<?

$num1 = 2;
$num2 = 4;

$return = gmp_invert($num1, $num2);

var_dump($return);

?>
bool(false)
HomeMenu