Bit shifting limitations
John Meacham
john at repetae.net
Sun Jul 13 20:13:15 UTC 2014
On Sun, Jul 13, 2014 at 12:42 PM, Henning Thielemann
<schlepptop at henning-thielemann.de> wrote:
> What kind of data do you have in mind, where both signed and unsigned shifts
> make sense?
It almost always matters and is independent of the type. For instance,
pretty much every one of these requires one or the other and it
doesn't necessarily coorespond to the signedness of the arguments
relying on C casts.
https://graphics.stanford.edu/~seander/bithacks.html
Generally, except for the very basic case of replacing a multiply with
a shift, you will want one behavior or the other.
Plus, it is exactly the distinction made in CPUs, they have
independent arithmetic and logical shift operations.
John
--
John Meacham - http://notanumber.net/
More information about the Libraries
mailing list