The OpenD Programming Language

ror

Bitwise rotate value left (rol) or right (ror) by count bit positions.

  1. T ror(T value, uint count)
    nothrow @safe @nogc pragma(inline, true) pure
    T
    ror
    (
    T
    )
    (
    const T value
    ,
    const uint count
    )
    if (
    __traits(isIntegral, T) &&
    __traits(isUnsigned, T)
    )
  2. T ror(T value)

Examples

ubyte a = 0b11110000U;
ulong b = ~1UL;

assert(rol(a, 1) == 0b11100001);
assert(ror(a, 1) == 0b01111000);
assert(rol(a, 3) == 0b10000111);
assert(ror(a, 3) == 0b00011110);

assert(rol(a, 0) == a);
assert(ror(a, 0) == a);

assert(rol(b, 63) == ~(1UL << 63));
assert(ror(b, 63) == ~2UL);

assert(rol!3(a) == 0b10000111);
assert(ror!3(a) == 0b00011110);

enum c = rol(uint(1), 0);
enum d = ror(uint(1), 0);
assert(c == uint(1));
assert(d == uint(1));

Meta