(PHP 5 >= 5.3.0, PHP 7, PHP 8)
gmp_testbit — Tests if a bit is set
$num
$index
Tests if the specified bit is set.
num
GMP 对象或 int ,或数字string。
index
The bit to test
Returns true if the bit is set in num, otherwise false.
true
false
An E_WARNING level error is issued when index is less than zero, and false is returned.
E_WARNING
示例 #1 gmp_testbit() example
<?php$n = gmp_init("1000000");var_dump(gmp_testbit($n, 1));gmp_setbit($n, 1);var_dump(gmp_testbit($n, 1));?>
以上示例会输出:
bool(false) bool(true)