Bitwise operators - Shift Right and And :)
http://php.net/manual/en/language.operators.bitwise.php
http://en.wikipedia.org/wiki/Bitwise_operation
$score = 2295;
echo((($score >> 2) & 1) == 1)? "1": "^1"; // 1
echo((($score >> 3) & 1) == 1)? "1": "^1"; // ^1
The question is what are you shifting and how many bits? Is it something with colors?
Using &
and >>
to convert hexadecimal to RGB (decimal).
$hex = 0xCCFF33; // my favourite :)
$r = $hex >> 16;
$g = ($hex & 0x00FF00) >> 8;
$b = $hex & 0x0000FF;
printf("rgb(%d,%d,%d)", $r, $g, $b); // rgb(204,255,51)
This is what happens: http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fbitshe.htm