gmp_and()是PHP中的一个内置函数,用于按位计算 和 由两个GMP编号组成( GNU多重精度:适用于大数字 ).
null
语法:
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_和()函数:
项目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
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END