Shift by K >= w

C
Author

Imad Dabbura

Published

August 15, 2023

If we shift an w-bit integer with k, most machines perform k mod w bit shift. For example, for 32-bit integers:

int i = 1024;
i >> 32     // Gives 1024 because 32 mod 32 = 0 -> i >> 0 = i
i >> 36     // Gives 64 bece 36 mode 32 = 4 -> i >> 4 = 64