10

Today I learned that right-shifting (a >> b) is just floor(a/2^b) and left shifting (a << b) is just (a * 2^b).

Comments
  • 3
    That's how the binary system work yeah!

    Also if you have n bits of data, the largest number you can store is (2^N)-1.

    Cheers 👍😄
  • 3
    Yep, just like in base 10, shifting digits multiplies and divides by 10
  • 0
    That's why one of the things I tell people that complain about javascripts lack of its is "just floor it" :v
Add Comment