gmp_and()是PHP中的内置函数,用于计算两个GMP数字的按位与(GNU Multiple Precision:用于大数)。
用法:
gmp_and($num1, $num2)
参数:此函数接受两个GMP编号$num1,$num2作为强制参数,如上面的语法所示。这些参数可以是PHP 5.6及更高版本中的GMP对象,或者也可以传递数字字符串,以便可以将这些字符串转换为数字。
返回值:此函数返回一个GMP编号,该编号与作为参数传递给它的GMP编号按位与。
例子:
Input : gmp_and("4", "2")
Output : 0
Input : gmp_and("9", "10")
Output : 8
以下示例程序旨在说明PHP中的gmp_and()函数:
程序1:程序将数字字符串作为GMP数字作为参数传递时,计算GMP数字的按位与。
<?php 
// PHP program to calculate the bitwise AND 
// GMP numbers passed as arguments  
  
// strings as GMP numbers 
$num1 = "10"; 
$num2 = "9"; 
  
// calculate the bitwise AND of $num1 and $num2 
$res = gmp_and($num1, $num2); 
  
echo $res; 
  
?>输出:
8
程序2:当GMP数字作为参数传递时,程序计算GMP数字的按位与。
<?php 
// PHP program to calculate the bitwise AND 
// GMP numbers passed as arguments  
  
// creating GMP numbers using gmp_init() 
$num1 = gmp_init(4); 
$num2 = gmp_init(2); 
  
//calculate the bitwise AND of $num1 and $num2 
$res = gmp_and($num1, $num2); 
echo $res; 
  
?>输出:
0
参考:
http://php.net/manual/en/function.gmp-and.php
相关用法
- p5.js sq()用法及代码示例
 - d3.js d3.map.has()用法及代码示例
 - PHP next()用法及代码示例
 - p5.js day()用法及代码示例
 - p5.js pow()用法及代码示例
 - CSS var()用法及代码示例
 - d3.js d3.map.set()用法及代码示例
 - PHP pow( )用法及代码示例
 - PHP pi( )用法及代码示例
 - PHP Ds\Map get()用法及代码示例
 - PHP Ds\Map put()用法及代码示例
 - p5.js str()用法及代码示例
 
注:本文由纯净天空筛选整理自akash1295大神的英文原创作品 PHP | gmp_and() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
