I was trying to make some code in C++ about “bitwise rotation” and I would like to make this by the left shif. I didn’t know how to code this, but I found a little code in “
if you want bitwise rotation over an arbitrary number of bits (for example 4), simply add a parameter to your function:
unsigned int rotl(unsigned int value, int shift, unsigned int width) { return ((value << shift) & (UINT_MAX >> (sizeof(int) * CHAR_BIT - width))) | (value >> (width - shift)); }