• PHP Video Tutorials

PHP - gmp_com() Function



Definition and Usage

The gmp_com() function is used to calculate one's complement.

Description

gmp_com() returns one's complement of the given GMP number.

Syntax

gmp_com ( GMP $a ) : GMP

Parameters

Sr.No Parameter & Description
1

a

It can a GMP resource number , a gmp object or a numeric string .

Return Values

PHP gmp_com() function returns one's complement of the given number. The returned value is a GMP number.

PHP Version

This function will work from PHP Version greater than 5.0.0.

Example 1

Working of gmp_com −

<?php
   $com = gmp_com("128");
   echo "The one's complement of 128 is :".$com;
?>

This will produce following result −

The one's complement of 128 is :-129

Example 2

Working of gmp_com with hexadecimal numbers −

<?php
   $com = gmp_com("0x80");
   echo "The one's complement of 0x80 is :".$com;
?>

This will produce following result −

The one's complement of 0x80 is :-129
php_function_reference.htm
Advertisements