Noob questions about Python

Arnaud Delobelle arnodel at googlemail.com
Thu Oct 18 13:51:58 EDT 2007


On Oct 18, 7:06 am, Ixiaus <parnel... at comcast.net> wrote:
[...]
> I know '<<' is shifting x over by n bits; but could you point me to
> some literature that would explain why it is the same as "x*2**n"?

I haven't got literature but I've got a (hopefully straightforward)
explanation:

In binary 2 is 10.  When you multiply by 10, you shift all your digits
left by 1 place.
When you multiply by 10**n (which is 1 followed by n zeroes), you
shift all your digits left by n places.

HTH

--
Arnaud





More information about the Python-list mailing list