PHP | gmp_或()函数

gmp_or()是PHP中的一个内置函数,用于按位计算 由两个GMP编号组成( GNU多重精度:适用于大数字 ).

null

语法:

gmp_or($num1, $num2)

参数: 此函数接受两个GMP数字,$num1,$num2作为强制参数,如上述语法所示。这些参数可以是PHP 5.6版及更高版本中的GMP对象,也可以传递数字字符串,以便将这些字符串转换为数字。

返回值: 此函数返回一个GMP编号,它是作为参数传递给它的GMP编号的按位或。

例如:

Input : gmp_or("4", "2")
Output : 6

Input : gmp_or("9", "10")
Output : 11

下面的程序演示了PHP中的gmp_或()函数:

项目1: 当作为GMP数字的数字字符串作为参数传递时,计算GMP数字的位或位的程序。

<?php
// PHP program to calculate the bitwise OR
//  GMP numbers passed as arguments
// strings as GMP numbers
$num1 = "10" ;
$num2 = "9" ;
// calculate the bitwise OR of $num1 and $num2
$res = gmp_or( $num1 , $num2 );
echo $res ;
?>


输出:

11

项目2: 当GMP数作为参数传递时,用于计算GMP数的按位OR的程序。

<?php
// PHP program to calculate the bitwise OR
//  GMP numbers passed as arguments
// creating GMP numbers using gmp_init()
$num1 = gmp_init(4);
$num2 = gmp_init(2);
// calculate the bitwise OR of $num1 and $num2
$res = gmp_or( $num1 , $num2 );
echo $res ;
?>


输出:

6

参考: http://php.net/manual/en/function.gmp-or.php

© 版权声明
THE END
喜欢就支持一下吧
点赞15 分享