I am trying to convert this C function into Python;
typedef unsigned long var; /* Bit rotate rightwards */ var ror(var v,unsigned int bits) { ret
i know its nearly 6 years old
I always find it easier to use string slices than bitwise operations.
def rotate_left(x, n): return int(f"{x:032b}"[n:] + f"{x:032b}"[:n], 2) def rotate_right(x, n): return int(f"{x:032b}"[-n:] + f"{x:032b}"[:-n], 2)