PHP | gmp_mul() Function

The gmp_mul() function in PHP is an inbuilt function which is used to multiply two GMP numbers (GNU Multiple Precision: For large numbers).

Syntax:

GMP gmp_mul ( GMP $num1, GMP $num2 )

Parameters: This function accepts two GMP numbers. It is mandatory parameters as shown in the above syntax. These can be a GMP object in PHP version 5.6 and later, or a numeric string provided that it is possible to convert the latter to a number. This function multiplies these two numbers and returns it.



Return Value: This function returns a GMP number which is multiplication of the two numbers passed as parameter.

Examples:

Input : num1 = "123456789"
        num2 = "987654321"
Output: 121932631112635269

Input : num1 = "9999999"
        num2 = "99999"
Output: 999989900001

Below programs illustrate the gmp_mul() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
$mul = gmp_mul("562817", "713645");
echo gmp_strval($mul);
?>

chevron_right


Output:

401651537965

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
$mul = gmp_mul("123456789", "987654321");
echo gmp_strval($mul); 
?>

chevron_right


Output:
Related Articles:

121932631112635269

Reference: http://php.net/manual/en/function.gmp-mul.php



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.