0

I found a question:

What wll be output of following

echo 4<< 5;

And the answer is 128

But i could not understand the the logic behind this.

Garry
  • 595
  • 3
  • 18
  • 1
    decimal `4` in binary is `00000100` (showing just 8 bits for simplicity)... `4 << 1` means shift those binary bits left `1` place to give binary `00001000` which is decimal `8`; `4 << 2` means shift those binary bits left `2` place to give binary `00010000` which is decimal `16`; `4 << 3` means shift those binary bits left `3` place to give binary `00100000` which is decimal `32`; etc – Mark Baker Dec 14 '15 at 22:21
  • Thanks @MarkBaker :) i got it now – Garry Dec 14 '15 at 22:26

0 Answers0