SyntaxFix
Write A Post
Hire A Developer
Questions
The short answer is:
int nBits = ceil(log2(N));
That's simply because pow(2, nBits) is slightly bigger than N.