ror

ror(B::BitArray{1}, i::Integer) -> BitArray{1}

Performs a right rotation operation.

Examples

In the Julia programming language, the function ror(B::BitArray{1}, i::Integer)

Performs a right rotation operation on a BitArray and returns the modified BitArray.

julia> ror(bitstring(0b1100), 2)
0b0011

Provide common examples of its use:

  1. Right rotate a binary number:

    julia> ror(bitstring(0b1010), 1)
    0b0101

    This example performs a right rotation of the binary number 0b1010 by 1 position.

  2. Rotate a bit array:

    julia> bits = BitArray([true, false, true, false]);
    julia> ror(bits, 2)
    4-element BitArray{1}:
    0
    1
    0
    1

    It performs a right rotation of the bit array bits by 2 positions.

  3. Rotate a bit array with negative index:
    julia> bits = BitArray([true, false, true, false]);
    julia> ror(bits, -1)
    4-element BitArray{1}:
    1
    0
    1
    0

    It performs a right rotation of the bit array bits by 1 position in the opposite direction.

Common mistake example:

julia> ror(bitstring(0b1100), -2)
ERROR: MethodError: no method matching ror(::String, ::Int64)

In this example, the input argument B is passed as a string (bitstring) instead of a BitArray. Make sure to provide a BitArray as the first argument to the ror function.

See Also

bitpack, bitunpack, bswap, flipbits!, htol, hton, isbits, ltoh, ntoh, rol, rol!, ror, ror!, signbit,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: