<p dir="ltr"><br>
On 18 Jun 2014 07:34, "MRAB" <<a href="mailto:python@mrabarnett.plus.com">python@mrabarnett.plus.com</a>> wrote:<br>
><br>
> On 2014-06-17 21:37, Antoine Pitrou wrote:<br>
>><br>
>> Le 17/06/2014 15:35, Ethan Furman a écrit :<br>
>>><br>
>>><br>
>>> I like the idea, but one question I have: when shifting, are the<br>
>>> incoming bits set to 0 or 1? Why?<br>
>><br>
>><br>
>> By convention, 0. Historically, that's how CPUs do it.<br>
>> (and also because it provides a quick way of multiplying / dividing by 2^N).<br>
>><br>
> That's sometimes known as a "logical shift".</p>
<p dir="ltr">My bitbashing-with-Python work was all serial communications protocol based, so logical shifts were what I wanted (I was also in the fortunate position of being able to tolerate the slow speed of doing them in Python, because HF radio comms are so slow the data streams to be analysed weren't very big).</p>
<p dir="ltr">> When shifting to the right, there's also the "arithmetic shift", which<br>
> preserves the most significant bit.<br>
><br>
> Do we need that too? (I don't think so.) If yes, then what should be<br>
> operator be? Just a 'normal' method call?</p>
<p dir="ltr">Wanting an arithmetic shift would be a sign that one is working with integers rather than arbitrary binary data, and ints or one of the fixed width types from NumPy would likely be a better fit. So leaving that out of any proposal sounds fine to me.</p>
<p dir="ltr">Cheers,<br>
Nick.</p>
<p dir="ltr">><br>
> _______________________________________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-ideas">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
> Code of Conduct: <a href="http://python.org/psf/codeofconduct/">http://python.org/psf/codeofconduct/</a></p>