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

gmp_divexact

Description

The gmp_divexact of GMP for PHP exact division of numbers.

Syntax

gmp_divexact(
    GMP|int|string $num1,
    GMP|int|string $num2
): GMP

Parameters

num1

The number being divided.

A GMP object, an int or a numeric string.

num2

The number that num1 is being divided by.

A GMP object, an int or a numeric string.

Return

Returns a GMP object.

Returns correct results only when it is known in advance that num2 divides num1.

Examples

1 · num1 num2 · GMP

<?

$num1 = 2;
$num2 = 3;

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

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

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

2 · num1 num2 · int

<?

$num1 = 2;
$num2 = 3;

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

var_dump($return);
object(GMP)#1 (1) {
  ["num"]=>
  string(19) "6148914691236517206"
}

3 · num1 num2 · string

<?

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

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

var_dump($return);
object(GMP)#1 (1) {
  ["num"]=>
  string(19) "6148914691236517206"
}