• PHP Video Tutorials

PHP - gmp_sub() Function



Definition and Usage

The gmp_sub() function gives the difference between two given numbers.

Description

The gmp_sub() function returns the result as GMP number after subtracting first number with second one.

Syntax

gmp_sub ( GMP $a , GMP $b ) : GMP

Parameters

Sr.No Parameter & Description
1

a

It can a GMP resource number , a gmp object or a numeric string.

2

b

It can a GMP resource number , a gmp object or a numeric string.

Return Values

PHP gmp_sub() function returns the a GMP number that is calculated by subtrating the first number with the second one.

PHP Version

This function will work from PHP Version greater than 5.0.0.

Example 1

Working of gmp_sub −

<?php
   $num = gmp_sub("1234", "234");	
   echo "The result is : ".$num;
?>

This will produce following result −

The result is : 1000

Example 2

Working of gmp_sub −

<?php
   $num = gmp_sub("0xFE", "0x80");	
   echo "The result is : ".$num;
?>

This will produce following result −

The result is : 126
php_function_reference.htm
Advertisements