The OpenD Programming Language

ror

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

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

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