doubt of a library function

while reading a tutorial of sparse table i came across a line “k=31-__builtin_clz(k+1); // k = log(k+1)” however if “__builtin_clz(k+1)” is log function then why we are using 31 there?

please help?

builtin_clz(k+1) != log(k + 1)

31-builtin_clz(k+1) == log(k + 1)

1 Like