How to set, clear, and toggle a single bit
@lebyy▲ 0 net votes
Problem: How can I set, clear, and toggle a bit? Fix (from the top answer): Setting a bit Use the bitwise OR operator ( | ) to set n th bit of number to 1 . // Can be whatever unsigned integer type you want, but // it's important to use the same type everywhere to avoid // per Note that it's undefined behavior to shift by more than the width of a Uint . The same applies to all remaining…