-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Suraj N. Kurapati wrote:
> Hi,
> 
> Minkoo Seo wrote:
>>> I'm using ruby for my research purpose, and as everyone knows
>>> computer science is all about log function whose base is 2.
>>>
>>> Unfortunately, Math module does not contain log2 though it has
>>> log10. What do you think about adding log2 to Math?
> 
> A few weeks ago, someone in the #ruby-lang channel on
> irc.freenode.net showed me an easy way of doing log2 in Ruby:

Correction: this calculates the ceiling of log2.

For my purposes, it was useful when determining how many bits are
necessary to represent an unsigned integer.

> 
> integer.to_s(2).length
> 
> 
> irb(main):011:0> 3.to_s(2)
> => "11"
> irb(main):012:0> 3.to_s(2).length
> => 2
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEWsh8mV9O7RYnKMcRAgjoAJ9Siy6nNiEMZupragmbDEg+ouqqTQCeLEOx
6GSZwDgEpU/O6DyAL6vLn7c=
=9Tld
-----END PGP SIGNATURE-----