Why does the following code output 128?
print 4 << 5;
?>
Answer
Because it's a bitwise operator. I think it means 4 multiplied to 2^5 because that operator means
Shift the bits of $a $b steps to the left (each step means "multiply
by two")
so it's five steps. It's 4 * 2 * 2 * 2 * 2 * 2 (But I'm guessing here; everything happens at bit level).
No comments:
Post a Comment