What is gmp_add() function in PHP?

The gmp_add() function is a PHP function that calculates the sum of two GMPGNU Multiple Precision Arithmetic Library numbers.

Syntax

gmp_add(GMP|int|string $num1, GMP|int|string $num2): GMP

Parameters

The function takes in two parameters, num1 and num2.

num1 and num2 can be a numeric string, GMP object, or of the integer type.

Return value

The function returns the sum of num1 and num2.

Code

<?php
$sum = gmp_add("1201034566", "7654321098");
echo gmp_strval($sum) . "\n";
?>

Expected output

8855355664

Free Resources