<?php
GMP gmp_or ( GMP|int|string $num1,
GMP|int|string $num2 )
where,
$num1 = The first GMP number
$num2 = The second GMP number
?>
OPERATOR | USE | NAME | WHAT DOES MAKES |
& | $a & $b | AND | Bits that are set in both $a and $b are set |
| | $a | $b | Or (inclusive) | Bits that are set in either $a or $b are set |
^ | $a ^ $b | xor Or (exclusive) |
Bits that are set in $a or $b but not both are set |
~ | ~$a | Not | Bits that are set in $a are not set, and vice versa |
<< | $a << $b | Shift Left | Shift the bits of $r1, $b steps to the left (each step means "multiply by two") |
>> | $a >> $b | Shift Right | Shift the bits of $r1, $b steps to the right (each step means "divide by two") |
ed48 |
<?php
// Run this code several times
$a = mt_rand(10, 50);
$b = mt_rand(10, 30);
$or01a = gmp_or($a, $b);
$or01b = $a|$b;
echo 'gmp_or( ' . $a .', ' . $b . ' ) = ' .
$or01a . '<br>or<br>' . $a . '|' . $b . ' = ' .
$or01b . '<br><br>where:<br><br>';
$bin01a = decbin($a);
$bin01b = decbin($b);
echo 'decbin( ' . $a . ' ) = ' . $bin01a . '<br>';
echo 'decbin( ' . $b . ' ) = ' . $bin01b . '<br>';
?>
<?php
echo "gmp_strval(gmp_or(\"111111\", \"2222222\")) = " .
gmp_strval(gmp_or("111111", "2222222")) . '<br><br>';
echo "gmp_strval(gmp_or(123123, 435234)) = " .
gmp_strval(gmp_or(123123, 435234)) . '<br><br>';
echo "gmp_strval(gmp_or(555, \"2342341123\")) = " .
gmp_strval(gmp_or(555, "2342341123")) . '<br><br>';
echo "gmp_strval(gmp_or(-1, 3333)) = " .
gmp_strval(gmp_or(-1, 3333)) . '<br><br>';
echo "gmp_strval(gmp_or(4545, -20)) = " .
gmp_strval(gmp_or(4545, -20)) . '<br><br>';
try {
var_dump(gmp_strval(gmp_or("test", "no test")));
} catch (\TypeError $e) {
echo $e->getMessage() . "<br><br>";
}
$n = gmp_init("987657876543456");
var_dump(gmp_strval(gmp_or($n, "34332")));
$n1 = gmp_init("987657878765436543456");
var_dump(gmp_strval(gmp_or($n, $n1)));
try {
var_dump(gmp_or(array(), 1));
} catch (\TypeError $e) {
echo $e->getMessage() . "<br><br>";
}
try {
var_dump(gmp_or(1, array()));
} catch (\TypeError $e) {
echo $e->getMessage() . "<br><br>";
}
try {
var_dump(gmp_or(array(), array()));
} catch (\TypeError $e) {
echo $e->getMessage() . "<br><br>";
}
?>