Welcome to little lamb

Code » test-msb » next » tree

[next] / 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;
}