Bitwise operations: Difference between revisions

Content added Content deleted
(Updated D code)
(Fixed bug in D code)
Line 322: Line 322:
<lang d>import std.stdio;
<lang d>import std.stdio;


T rot(T)(T x, int shift) {
T rot(T)(in T x, in int shift) pure nothrow {
return (x >> shift) | (x << (T.sizeof * 8 - shift));
return (x >>> shift) | (x << (T.sizeof * 8 - shift));
}
}