From: Curt Hibbs Date: 2005-11-24T03:28:22+09:00 Subject: Re: How convert an integer to a bit array ------=_Part_10684_6246159.1132770497044 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 11/23/05, Ryan Leavengood wrote: > > On 11/22/05, James Edward Gray II wrote: > > > > >> bits =3D Array.new(8) { |i| 7[i] }.reverse! > > =3D> [0, 0, 0, 0, 0, 1, 1, 1] > > And the winner by a nose is................................. > ............................... > ............................... > James!!! > > ---------------------------------------------------------------------- > | QuickBench Session Started | > | 300000 Iterations | > ---------------------------------------------------------------------- > user system total real > 1. 244.to_ba 3.296000 0.015000 3.311000 ( 3.313000) > 2. Array.new(8) { |i| ... 2.782000 0.000000 2.782000 ( 2.781000) > ---------------------------------------------------------------------- > | Fastest was <2. Array.new(8) { |i| ...> | > ---------------------------------------------------------------------- > > I'm glad you posted this because it is elegant and fast. OK, now I'll > stop spamming this thread with benchmark results :) > Cool! Thanks for doing the benchmark. Curt ------=_Part_10684_6246159.1132770497044--