Use http://tohtml.com/ and http://bedaux.net/cpp2html/ for easy syntax highlighting in your blogger posts. (I tried this with that but it doesn't seem to work). Now the Java stuff (easily portable to C, C++ and many other languages): // Returs bit a to b (> a). lsb is bit 0, msb is 63, is returned as String in normal order (msb first) public static String getBits(long n, int a, int b) { String bs = "" ; for ( int i = a ; i < = b ; i + + ) bs = ( 1 & ( n > > i ) ) + bs ; return bs ; } // Calculates floored log2 by finding position of highest set bit. // Ignores very highest bit of long (63rd). public static int log2(long n) { long m = 1 L < < 62 ; int i = 62 ; while ( ( n & m ) = = 0 & & i > 0 ) { m = m > > 1 ; i - - ; } return i ; } /** ...