# Cost of shifting a number

I was wondering what would be a time complexity of shifting a binary or a decimal number? For example: 0011, when I shift it left I get 0001.

I was thinking that the time complexity is $\Theta(n)$, because we have to shift every number.

I need it to calculate $m*{b^\frac{n}{2}}$, where $m$ is some number and $b$ might be 2 (in case of binary) or 10 (decimal). Therefore instead of multiplication, I just shift to multiply, and therefore complexity is $\Theta(n)$.

Am I correct or is my thinking wrong?

• Which machine model? – Raphael Mar 5 '15 at 19:21
• It is not machine model - it is software: java. Where there was a shift function. Sorry for not being specific – Johhny Bravo Mar 6 '15 at 2:01
• It still depends on the machine (model). How do VM and CPU implement shift? – Raphael Mar 6 '15 at 7:31

• $O(n)$ with respect to what machine model? How many bits are in your CPU register? What happens if you want to shift more bits than that? – David Richerby Mar 5 '15 at 20:29