Computer >> Computer tutorials >  >> Programming >> PHP

gmp_sub() function in PHP


The gmp_sub() function returns the subtraction of the two GMP numbers.

Syntax

gmp_sub(n1, n2)

Parameters

  • n1: The first GMP number. It can be GMP object in PHP version 5.6 and later. Can also be numeric strings.

  • n2: The second GMP number. It can be GMP object in PHP version 5.6 and later. Can also be numeric strings.

Return

The gmp_sub() function returns the subtraction of n1 and n2.

Example

The following is an example:

<?php
   $n1 = "30";
   $n2 = "5";
   $res = gmp_sub($n1, $n2);
   echo $res; ;
?>

Output

The following is the output:

25