I have an array of signed ints, and I would like to divide by 2^n. I currently use this routine to do it: int out = in >= 0 ? int >> n : -((int & 0x7FFFFFFF) >> n);
Is there a better way that does not involve a branch?
I have an array of signed ints, and I would like to divide by 2^n. I currently use this routine to do it: int out = in >= 0 ? int >> n : -((int & 0x7FFFFFFF) >> n);
Is there a better way that does not involve a branch?