Using bitwise operations
问题 How often you use bitwise operation "hacks" to do some kind of optimization? In what kind of situations is it really useful? Example: instead of using if: if (data[c] >= 128) //in a loop sum += data[c]; you write: int t = (data[c] - 128) >> 31; sum += ~t & data[c]; Of course assuming it does the same intended result for this specific situation. Is it worth it? I find it unreadable. How often do you come across this? Note: I saw this code here in the chosen answers :Why is processing a sorted