Wednesday, June 17, 2026
HomeLanguagesPHP | gmp_mul() Function

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:




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


Output:

401651537965

Program 2:




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


Output:
Related Articles:

121932631112635269

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

RELATED ARTICLES

Most Popular

Dominic
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6898 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS