If you have interesting with architecture of open source application, then this book will be one of them.
You can read from online.
In java we didn't have log2n library but we have log10n library, so we can leverage with that
public static double log2(double num)
Note: if you want to use that correctly, remember with the (double) cast for accuracy.