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

gmp_sub

Description

The gmp_sub of GMP for PHP subtracts numbers.

Syntax

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

Parameters

num1

The number being subtracted from.

A GMP object, an int or a numeric string.

num2

The number subtracted from num1.

A GMP object, an int or a numeric string.

Return

Returns a GMP object.

Examples

1 · num1 num2 · GMP

<?

$num1 = 2;
$num2 = 3;

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

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

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

2 · num1 num2 · int

<?

$num1 = 2;
$num2 = 3;

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

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

3 · num1 num2 · string

<?

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

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

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