Bits rotations
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Oct 17 20:07:59 PDT 2012
On Thu, Oct 18, 2012 at 04:55:38AM +0200, Adam D. Ruppe wrote:
> On Thursday, 18 October 2012 at 02:36:59 UTC, bearophile wrote:
> >uint foo(in uint x) pure nothrow {
> > return (x << 11) | (x >> (32 - 11));
> >}
>
> Why would you write that instead of using rol(x, 11) today?
>
> uint rol(in uint x, in uint y) pure nothrow {
> return (x << y) | (x >> (32 - y));
> }
[...]
> Perhaps we should add that rol function to the stdlib to save people
> from quickly doing it themselves, but there's no need to do anything
> beyond this simple function.
+1, add this to core.bitop.
T
--
If you compete with slaves, you become a slave. -- Norbert Wiener
More information about the Digitalmars-d
mailing list