PHP gmp_abs() Function Last Updated : 23 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The gmp_abs() is an in built function in PHP which is used to calculate the absolute value of a GMP number (GNU Multiple Precision : For large numbers). Syntax : gmp_abs( $num ) Parameters : This function accepts a GMP number as parameter as shown in the above syntax. It 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 calculates the absolute value of this number and returns it. Return Value : This function returns a positive GMP number which is the absolute value of the number passed as parameter. Examples: Input : "16497863358" Output : 16497863358 Input : "-16497863358" Output : 16497863358 Below programs illustrate the use of gmp_abs() function in PHP : Program 1: php <?php // Passing a positive number // as a numeric string $val1 = gmp_abs("16497863358"); // Passing a negative number // as a numeric string $val2 = gmp_abs("-16497863358"); echo gmp_strval($val1); echo "\n"; echo gmp_strval($val2); ?> Output: 16497863358 16497863358 Program 2: php <?php // Passing a positive number // as a numeric string $val1 = gmp_abs("1897023411"); // Passing a negative number // as a numeric string $val2 = gmp_abs("-1897023411"); echo gmp_strval($val1); echo "\n"; echo gmp_strval($val2); ?> Output: 1897023411 1897023411 Reference: http://php.net/manual/en/function.gmp-abs.php Comment More infoAdvertise with us Next Article PHP gmp_abs() Function R RICHIK BHATTACHARJEE Follow Improve Article Tags : Misc Web Technologies PHP Practice Tags : Misc Similar Reads PHP | gmp_and() Function The gmp_and() is an inbuilt function in PHP which is used to calculate the bitwise AND of two GMP numbers(GNU Multiple Precision : For large numbers). Syntax: gmp_and($num1, $num2) Parameters: This function accepts two GMP numbers, $num1, $num2 as mandatory parameters as shown in the above syntax. T 2 min read PHP abs() Function The abs() function is an inbuilt function in PHP which is used to return the absolute (positive) value of a number. The abs() function in PHP is identical to what we call modulus in mathematics. The modulus or absolute value of a negative number is positive. Syntaxnumber abs( value )ParametersThe ab 1 min read PHP | gmp_cmp() Function The gmp_cmp() is an inbuilt function in PHP which is used to compare two GMP numbers(GNU Multiple Precision : For large numbers). Syntax: gmp_cmp($num1, $num2) Parameters: This function accepts two GMP numbers $num1 and $num2 as mandatory parameters as shown in the above syntax for comparing. These 2 min read PHP | gmp_com() Function The gmp_com() is an inbuilt function in PHP which is used to calculate the one's complement of a GMP number(GNU Multiple Precision : For large numbers). Syntax: gmp_com($num) Parameters: This function accepts a GMP number $num as a mandatory parameter as shown in the above syntax. This parameter can 2 min read PHP | gmp_clrbit() Function The gmp_clrbit() function is an in-built function in PHP which clears a bit of a GMP number (GNU Multiple Precision). The gmp_clrbit() function sets the bit at a specified index in a GMP number to 0. The index starts at zero from the least significant bit. Syntax : gmp_clrbit( $num, $index ) Paramet 2 min read Like