Arquivos
hhvm/hphp/test/quick/bitwise.php
T
ptarjan 503f75d08b Rename test directories
These names don't make sense now that we run both suites the same
way.
2013-04-17 09:06:51 -07:00

39 linhas
688 B
PHP

<?php
function f() {
$x = 204; // 11001100 in binary
$y = 170; // 10101010 in binary
echo ($x ^ $y); // 01100110 in binary
echo "\n";
echo ($x & $y);
echo "\n";
echo ($x | $y);
echo "\n";
echo (~$x);
echo "\n";
}
f();
// Pairwise probe.
function probe($l, $r) {
echo "-------\n";
echo "left: "; var_dump($l);
echo "right: "; var_dump($r);
$v = ($l & $r); var_dump($v);
$v = ($l | $r); var_dump($v);
$v = ($l ^ $r); var_dump($v);
$v = (~$l); var_dump($v);
}
function main() {
$i = 0x3;
$data = array(15, "7", "not an int. at all.");
foreach ($data as $left) {
foreach ($data as $right) {
probe($left, $right);
}
}
}
main();