If by 2**x
you mean $2^x$, then yes. We can use the left-shitshift operator <<
, i.e. we compute 1 << x
. This is lightning-fast as it is a primitive machine instruction in every processor I know of. This can not be done with any base other than 2. Moreover, integer exponentiation will always be faster than real exponentiation, as floating point numbers take longer to multiply.
Fixed subtle but significant spelling error