Welcome to little lamb

Code » test-msb » master » tree

[master] / src / m0.c

#include <stdint.h>

typedef uint64_t u64;

int msb(u64 v)
{
    if (!v) return 0;

    int n;
    for(n = 0; v >>= 1; ++n)
        ;
    return n + 1;
}