Re: [PATCH] fix potential infinite loop given large unsigned integer
- From
Ryan Flynn <parseerror@gmail.com>
- Date
- Aug 10, 2009, 16:17 UTC
- Message-ID
- <a3f15ee60908100917k2a2d6de7ndd5e4ddd1d926cc3@mail.gmail.com>
- In-Reply-To
- <alpine.DEB.1.00.0908101421340.8324@intel-tinevez-2-302>
On Mon, Aug 10, 2009 at 8:24 AM, Johannes Schindelin<Johannes.Schindelin@gmx.de> wrote:
Show 29 quoted lines
> Hi,
>
> On Mon, 10 Aug 2009, Erik Faye-Lund wrote:
>
>> On Mon, Aug 10, 2009 at 7:24 AM, Christian
>> Couder<chriscool@tuxfamily.org> wrote:
>> >> log10() appears to be C99, but can be emulated on earlier C-versions by
>> >> doing #define log10(x) (log(x) / log(10.0))
>> >
>> > That would mean linking with -lm?
>>
>> I guess so. Are we currently trying to avoid linking to the math-parts
>> of libc?
>
> Yes.
>
> I guess we could fix the overflow thing very easily, though:
>
> static unsigned int digits_of_number(unsigned int number) {
> unsigned int result;
> for (result = 1; number; number /= 10, result++)
> ; /* do nothing */
> return result;
> }
>
> Ciao,
> Dscho
>
>whoops, actually yours: digits_of_number(1) -> 2