> Clearly, floor of base 2 log of x is (WORDBITS-lzc(x)).
Uh, is it?
> Clearly, floor of base 2 log of x is (WORDBITS-lzc(x)).
Uh, is it?
[0] http://web.stonehill.edu/compsci/History_Math/math-read.htm
HN discussion: https://news.ycombinator.com/item?id=14232977
> Uh, is it?
Of course, that is intuitively obvious to even the most casual observer. ;)
http://www.urbandictionary.com/define.php?term=intuitively%2...
Basically, you're using a binary representation, so everything is in powers of two. Let's just talk integers. 2^n is just the nth bit set and a bunch of zeros. Every number between 2^n and 2^n+1 has the nth digit set and some lower digits. The log base 2 is between n and n+1. So the floor is n. So, biggest digit set=floor of log base 2.
Once you've grasped that principle, the exact details are, in fact, clear. :)
> Clearly, floor of base 2 log of x is (WORDBITS-lzc(x)).
Yes. Because the 1st bit indicates the MSB of the number and the way binary works
If you have only one bit set, then WORDBITS-lzc(x) is log2(x). If you have less significant bits enabled that won't be enough to bump the floor to the next number
The "clearly" stuff is just shorthand for "I assume you know this because its foundational to understanding the thing were talking about now / or I'm too lazy to explain this now / or this is so far off-topic that this isnt the place / etc. etc" . Nothing more - it can be read as arrogance on the authors part but I think thats an uncharitable interpretation.
Grrr x)