• __ROR__ : ROtate Right (circular rotation to the right)
    • __ROR1__ : uint8
    • __ROR2__ : uint16
    • __ROR3__ : uint24
    • __ROR4__ : uint32
  • __ROL__ : ROtate Left (circular rotation to the left)
    • __ROL1__ : uint8
    • __ROL2__ : uint16
    • __ROL3__ : uint24
    • __ROL4__ : uint32

def __ROL__(num, count, bits=8):
    return ((num << count) | (num >> (bits - count))) & ((0b1<<bits) - 1)

def __ROR__(num, count, bits=8):
    return ((num >> count) | (num << (bits - count))) & ((0b1<<bits) - 1)

Ref : https://www.geeksforgeeks.org/rotate-bits-of-an-integer/

+ Recent posts