Have you seen this page:http://www.cut-the-knot.com/binary.shtml?
http://www.cut-the-knot.com/binary.shtml
?