Hi everyone,

I'm trying to figure out if there is any way to do exponents using bit shifting.

I know the following:

x *= 2 --> x << 2

x /= 2 --> x >> 2

pow(2, x) --> 1 << x

i'm looking for the equivalent bitshift, if any, for x = pow(x, 2) where x can be any number

i've seen the following for x = 5

x = 0101 (5)

x << 2 --> 010100 (20)

x + 0101 --> 011001 (25)

but then that is not true for other numbers :(