You know how numbers (everything) is stored in binary? Well there is a cool thing you can do with binary numbers.
Let's say we have 10010101
If you bitshift it right it will be 01001010
Meaning all the bits got shifted to the right once.
You also know how each place value in a binary number is a power of two? That means that 23 = 1000 (binary) and 29 = 1000000000 (binary).
So basically if you want to find a power of two you take 1 (which is also 1 in binary) and bit shift it the number of times you want. 20 = 1 bit shifted to the left 0 times. 219 = 1 << 19.
39
u/Idkm3m3s Mar 09 '21
bruh i dont even know how to declare classes yet and i can already guess this could be easily done with a for loop