PHP | gmp_add() for adding large numbers Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report The gmp_add() is a built-in function in PHP which is used to add two GMP numbers (GNU Multiple Precision : For large numbers). Syntax : gmp_add ( $num1, $num2 ) Parameters: This function accepts two GMP numbers as 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 adds these two numbers and returns it. Return Value: This function returns a GMP number which is sum of the two numbers passed as parameter. Examples: Input : "123456789", "987654321" Output : 1111111110 Input : "5628179032615", "7136454221086" Output : 12764633253701 Below programs illustrate the gmp_add() function in PHP : Program 1 : php <?php $sum = gmp_add("5628179032615", "7136454221086"); echo gmp_strval($sum); ?> </div> Output: 12764633253701 Program 2: php <?php $sum = gmp_add("123456789", "987654321"); echo gmp_strval($sum); ?> Output: 1111111110 Reference: https://www.php.net/manual/en/function.gmp-add.php Create Quiz Comment R RICHIK BHATTACHARJEE Follow 1 Improve R RICHIK BHATTACHARJEE Follow 1 Improve Article Tags : Misc Web Technologies PHP PHP-math Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like