<?php
void gmp_setbit ( GMP $num,
int $index,
bool $value = true )
where,
$num = The value to modify
$index = The index of the bit to set
$value = To control the bit set
?>
<?php
$a01 = gmp_init('1000000');
$arri01 = [0, 1, 2, 3, 4, 5];
foreach($arri01 as $i01)
{
$c01 = gmp_setbit($a01, $i01, TRUE);
$t01 = gmp_testbit($a01, $i01);
if($t01 == true)
{
echo 'The bit ( ' . $a01 . ', ' . $i01 . ' ) now it\'s set<br><br>';
}
else
{
echo 'The bit ( ' . $a01 . ', ' . $i01 . ' ) is NOT yet set<br><br>';
}
}
?>
<?php
$a02 = gmp_init('1000000');
$arri02 = [0, 1, 2, 3, 4, 5];
foreach($arri02 as $i02)
{
$c02 = gmp_setbit($a02, $i02, FALSE);
$t02 = gmp_testbit($a02, $i02);
if($t02 == true)
{
echo 'The bit ( ' . $a02 . ', ' . $i02 . ' ) now it\'s set<br><br>';
}
else
{
echo 'The bit ( ' . $a02 . ', ' . $i02 . ' ) is NOT yet set<br><br>';
}
}
?>
<?php
$a03 = gmp_init('0xF4240');
$arri03 = [0, 1, 2, 3, 4, 5];
$b03 = mt_rand(0, 1);
// 0 = FALSE and 1 = TRUE
foreach($arri03 as $i03)
{
$c03 = gmp_setbit($a03, $i03, $b03);
$t03 = gmp_testbit($a03, $i03);
if($t03 == true)
{
echo 'The bit ( ' . $a03 . ', ' . $i03 . ' ) now it\'s set<br><br>';
}
else
{
echo 'The bit ( ' . $a03 . ', ' . $i03 . ' ) is NOT yet set<br><br>';
}
}
?>