From: "Suraj N. Kurapati" Date: 2006-08-08T06:31:48+09:00 Subject: Re: nextPowerOf2(n) -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Suraj N. Kurapati wrote: > def nextPowerOf2(n); n.to_s(2).length; end Ah, well this doesn't actually produce your desired output. Nevertheless, this is the way to calculate the number of bits required to represent an integer (signed & unsigned)! -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFE17EjmV9O7RYnKMcRAt4qAKCaKv5KNaMClpQg+vEBWGKhBst/4QCeIg/X zL6KQJ9SQmCrMCqEn0WLLGE= =bDAS -----END PGP SIGNATURE-----