This forum is now read-only. Please use our new forums! Go to forums

banner
Close banner
0 points
Submitted by Mike Van de Kamp
over 9 years

What is meant by this quote on 6/14?

In the explanation it says:

“This operation is mathematically equivalent to floor dividing and multiplying by 2 (respectively) for every time you shift,” So how then? the example 0b000001 << 2 == 0b000100 (1 << 2 = 4) (1//2)*2? this would mean 0*2=0 so this is not what it meant.. So my question is what is exactly meant by this mathematical equivalence?

Answer 5416d4d19c4e9d7ba500397a

2 votes

Permalink

a << 1 is the same as a * 2 and a >> 1 is the same as a // 2 if a is an integer

points
Submitted by Jonatan
over 9 years

1 comments

Mike Van de Kamp over 9 years

Thx!