gmp_clrbit()函数是PHP中的一个内置函数,用于清除gmp编号的一部分 (GNU多精度) .gmp_clrbit()函数将位设置为指定的值 指数 以GMP编号 0 .索引从最低有效位的0开始。
null
语法:
gmp_clrbit( $num, $index )
参数: 该函数接受两个必需参数 $num 和 美元指数 如上面的语法所示。这些参数是:-
- $num: 它可以是PHP5.5中的GMP数字资源,也可以是PHP5.6及更高版本中的GMP对象,或者可以将数字字符串传递给函数,前提是可以将这些字符串转换为数字。
- $index: 要清除的位的索引。索引从0开始,其中索引0表示最低有效位。。
返回值: 此函数返回一个GMP编号(在PHP 5.5及更早版本中)或一个GMP对象(在PHP 5.6及更高版本中),这是在指定索引的位设置为0后形成的数字。
例如:
Input : $num = 255, $index = 0 Output : 254 Input : $num = 128, $index = 7 Output : 0
下面的程序演示了gmp_clrbit()函数:
方案1 :
<?php // PHP program to illustrate // gmp_clrbit() function $num = gmp_init(255); gmp_clrbit( $num , 0); // index starts at 0, least significant bit echo gmp_strval( $num ); ?> |
输出 :
254
方案2 :
<?php // PHP program to illustrate // gmp_clrbit() function $num = gmp_init( "314567128" ); gmp_clrbit( $num , 8); // index starts at 0, least significant bit echo gmp_strval( $num ); ?> |
输出 :
314566872
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END