VOOZH about

URL: https://www.geeksforgeeks.org/php/php-gmp_sub-function/

⇱ PHP | gmp_sub() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PHP | gmp_sub() Function

Last Updated : 11 Jul, 2025
The gmp_sub() is an in-built function in PHP which returns the subtraction of the two GMP numbers.(GNU Multiple Precision: For large numbers) Syntax:
gmp_sub($num1, $num2)
Parameters: This function accepts two GMP numbers $num1 and $num2 as mandatory parameters shown in the above syntax. These parameters can be a GMP object in PHP version 5.6 and later, or we are also allowed to pass a numeric string provided that it is possible to convert that string to a number. Return Value: The function returns the subtraction of two numbers $num1 and $num2. Examples:
Input : $num1=5 , $num2=10
Output : -5 

Input : $num1=7 , $num2=1
Output : 6 
Below programs illustrate the gmp_sub() function: Program 1: The program below demonstrates the working of gmp_sub() function when GMP number are passed as arguments. Output:
-101
Program 2: The program below demonstrates the working of gmp_sub() when numeric string are passed as arguments. Output:
6
Reference: https://www.php.net/manual/en/function.gmp-sub.php
Comment
Article Tags: