x86 most significant bit code example
Example: most significant bit using clz
int clz(int N) {
return N ? 32 - __builtin_clz(N) : -inf;
}
int clz(unsigned long long N) {
return N ? 64 - __builtin_clzll(N) : -inf;
}
int clz(int N) {
return N ? 32 - __builtin_clz(N) : -inf;
}
int clz(unsigned long long N) {
return N ? 64 - __builtin_clzll(N) : -inf;
}