PHP - gmp_and() Function
Definition and Usage
The gmp_and() function returns the bitwise AND comparision of two numbers.
Description
gmp_and() calculates Bitwise AND of two given numbers.
Syntax
gmp_and ( GMP $num1 , GMP $num2 ) : GMP
Parameters
| Sr.No | Parameter & Description |
|---|---|
| 1 |
num1 It can a GMP resource number , a gmp object or a numeric string . |
| 2 |
num2 It can a GMP resource number , a gmp object or a numeric string . |
Return Values
PHP gmp_and() function returns a GMP number that is generated from bitwise comparison.
PHP Version
This function will work from PHP Version greater than 5.0.0.
Example 1
Working of gmp_and −
<?php $num1 = '4'; $num2 = '8'; $num3 = gmp_and($num1, $num2); echo "The BITWISE AND of 4 and 8 is :".$num3; echo "<br/><br/>"; $num4 = '12'; $num5 = '25'; $num6 = gmp_and($num4, $num5); echo "The BITWISE AND 12 and 15 is :".$num6; ?>
This will produce following result −
The BITWISE AND of 4 and 8 is :0 The BITWISE AND 12 and 15 is :8
Example 2
Using GMP numbers −
<?php $num1 = gmp_init(4); $num2 = gmp_init(8); $num3 = gmp_and($num1, $num2); echo "The BITWISE AND of 4 and 8 is :".$num3; echo "<br/><br/>"; $num4 = gmp_init(12); $num5 = gmp_init(25); $num6 = gmp_and($num4, $num5); echo "The BITWISE AND 12 and 15 is :".$num6; ?>
This will produce following result −
The BITWISE AND of 4 and 8 is :0 The BITWISE AND 12 and 15 is :8
php_function_reference.htm
Advertisements