>From: Timothy Hunter <TimHunter / nc.rr.com> >Reply-To: ruby-talk / ruby-lang.org >To: ruby-talk / ruby-lang.org (ruby-talk ML) >Subject: Re: Question: Counting integers >Date: Mon, 26 Jun 2006 09:35:26 +0900 > >Dark Ambient wrote: >>I 've come across this somewhere but right now it's escapeing me. >> >>x = 100 , so I want to find out how many digits are in that number. >> >>?? >>Tia >>Stuart >> >irb(main):001:0> x = 100 >=> 100 >irb(main):002:0> x.to_s.length >=> 3 > irb(main):001:0> x = 100 => 100 irb(main):002:0> Math.log10(x+1).ceil => 3 Regards, Park Heesob