Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int __clzsi2(unsigned x)
- {
- // This uses a binary search (counting down) algorithm from Hacker's Delight.
- unsigned y;
- int n = 32;
- y = x >>16; if (y != 0) {n = n -16; x = y;}
- y = x >> 8; if (y != 0) {n = n - 8; x = y;}
- y = x >> 4; if (y != 0) {n = n - 4; x = y;}
- y = x >> 2; if (y != 0) {n = n - 2; x = y;}
- y = x >> 1; if (y != 0) return n - 2;
- return n - x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement