PHP | gmp_sub() Function Last Updated : 14 Apr, 2018 Comments Improve Suggest changes Like Article Like Report 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. php <?php // PHP program to subtract two // two numbers // GMP number as arguments $num1 = gmp_init("101", 2); $num2 = gmp_init("1010", 2); // 5-10 = -5 $sub = gmp_sub($num1, $num2); // gmp_strval converts GMP number to string // representation in given base(default 10). echo gmp_strval($sub, 2); ?> Output: -101 Program 2: The program below demonstrates the working of gmp_sub() when numeric string are passed as arguments. php <?php // PHP program to subtract two // two numbers // numeric strings number as arguments $num1 = "7"; $num2 = "1"; // 7-1 = 6 $sub = gmp_sub($num1, $num2); echo $sub; ?> Output: 6 Reference: http://php.net/manual/en/function.gmp-sub.php Comment More infoAdvertise with us Next Article PHP | gmp_sub() Function C ChetnaAgarwal Follow Improve Article Tags : Misc Web Technologies PHP PHP-gmp Practice Tags : Misc Similar Reads PHP | gmp_sqrt() Function The gmp_sqrt() is a built-in function in PHP which is used to calculate the square root of a GMP number (GNU Multiple Precision : For large numbers). This function returns only the integral part of the square root of the GMP number. Syntax: gmp_sqrt ( $num ) Parameters: This function accepts a GMP n 2 min read PHP | gmp_sign() Function The gmp_sign() is an in-built function in PHP which checks the sign of a given GMP number (GNU Multiple Precision: For large numbers). Syntax: gmp_sign($num) Parameters: This function accepts one GMP number $num as mandatory parameter shown in the above syntax. This parameter can be a GMP object in 2 min read PHP | gmp_setbit() Function The gmp_setbit() function is an inbuilt function in PHP which is used to set the bit index in given $num. Syntax: void gmp_setbit( GMP $num, int $index, bool $bit_on ) Parameters: This function accepts three parameters as mentioned above and described below: $num: It is a required parameter. This pa 2 min read PHP | gmp_scan1() Function The gmp_scan1() is an inbuilt function which is used to scan "1" in the GMP number(GNU Multiple Precision : For large numbers) starting from given index which move towards most significant bits in the number. Syntax: gmp_scan1($num, $index) Parameters: This function accepts two parameters as explain 2 min read PHP | gmp_scan0() Function The gmp_scan0() is an inbuilt function which is used to scan "0" in a GMP number(GNU Multiple Precision : For large numbers) starting from given index which move towards most significant bits in the number. Syntax: gmp_scan0($num, $index) Parameters: This function accepts two parameters as explained 2 min read Like