Python 3, 38 bytes ------ def f(n):return(-1,len(bin(n))-3)[n>0] `bin(n)` produces a string like `0b100`, so you have to subtract 3, not just 1. `(a,b)[condition]` is a trick I took from [Tips for golfing in Python][1]. [1]: http://codegolf.stackexchange.com/a/62/11333