Thursday, February 21, 2019

echo - Strange print behaviour in PHP?




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

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...