Are bitwise operators slower than common loops like a for loop?
Do bitwise operators like &
(AND) take more runtime than common for
loops?
Is bitwise shift more “efficient” than a for loop?
I just started going through “Data Structures and Algorithms in C++” and in one of the intro exercises they ask to write a function which returns powers of 2 and takes the exponent n
as an argument. They ask not to multiply 2 by itself n
times as there are more efficient ways of doing it.