> Could I write it in just 1 line ?
>
> find the first value greater than d, in a list (special one :  each
> value is the double of the previous...)
> then give me the index of this value (with special case ...)
>
>       i =
> ([0.5,1.0,2.0,4.0,8.0,16.0,32.0,64.0,128.0,256.0,512.0,1024.0,2048.0].select
> {|v| v if v >= d }).first
>
>       zl = d <0.5  ? 0 :
> [0.5,1.0,2.0,4.0,8.0,16.0,32.0,64.0,128.0,256.0,512.0,1024.0,2048.0].index(i)

Hi Joss,

In this specific case, you could simply do:

  (Math.log(d)/Math.log(2) + 1).ceil

Which is a different kind of solution, and doesn't need the array.

Cheers,
  Benj