if (potentially_large_value >= 32) bit_pattern = 0; else bit_pattern = bit_pattern << potentially_large_value;
I might also note that in the specific instance, potentially_large_value was the length of a string in memory.