Wed 30 Nov 2005
Posted by pete under Uncategorized
Comments Off on Integer Selection
A branchless, lookup-free, alternative to code like if (a<b) x=c; else x=d; is ((((a-b) >> (WORDBITS-1)) & (c^d)) ^ d). This code assumes that the shift is signed, which, of course, C does not promise.
No Responses to “ Integer Selection ”
Sorry, comments for this entry are closed at this time.