From: Uma Geller Date: 2007-01-15T03:25:01+09:00 Subject: Re: how to translate base 10 number into base 2 number TAWLWTDIT [0xFF].pack("c").unpack("b8") there's a whole lotta ways to do it :-) On 14/01/07, khaines@enigo.com wrote: > On Mon, 15 Jan 2007, chen li wrote: > > > Hi all, > > > > I want to write a method to tranlate base 10 number > > into base 2 number. I want to call the method within > > itself. But it doesn't work. What is the right way > > to do something like this? > > This doesn't answer your question, but in case you were not aware, Ruby > will do this conversion for you: > > > a = 125 > puts a.to_s(2) > 1111101 > > > Kirk Haines > > > -- best, UG --- Uma Geller http://umageller.wordpress.com