From: Johannes Schindelin Date: Mon, 10 Aug 2009 16:53:34 GMT Subject: Re: [PATCH] fix potential infinite loop given large unsigned integer Message-ID: In-Reply-To: Hi, [please cull the quoted text to what you are actually replying to. Thanks] On Mon, 10 Aug 2009, Ryan Flynn wrote: > On Mon, Aug 10, 2009 at 8:24 AM, Johannes > Schindelin wrote: > > > > static unsigned int digits_of_number(unsigned int number) { > >    unsigned int result; > >     for (result = 1; number; number /= 10, result++) > >         ; /* do nothing */ > >     return result; > > } > > whoops, actually yours: digits_of_number(1) -> 2 static unsigned int digits(unsigned int number) { unsigned int result; for (result = 1; (number /= 10); result++) ; /* do nothing */ return result; } I'm sorry, I forgot the "something like this" in my mail. This version is actually tested. It has non-optimal runtime, but then, it does not really matter. Ciao, Dscho