Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Sort of trivial code challenge - may be interesting to you anyway
Date: Thu, 05 Mar 2026 20:06:22 -0800
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <86ms0lbo01.fsf@linuxsc.com>
References: <10n80sc$3soe4$1@dont-email.me> <10o6vat$258sq$1@raubtier-asyl.eternal-september.org> <10o7438$2737q$2@dont-email.me> <10o92e1$2r6rf$1@raubtier-asyl.eternal-september.org> <10obb37$3jler$1@dont-email.me> <86cy1ic5fm.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Fri, 06 Mar 2026 04:06:25 +0000 (UTC)
Injection-Info: dont-email.me; posting-host="b0f5cdf16a02d5dcd9e415cfd7cb6e85"; logging-data="405301"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bp/mSrFEXyXAw07PSqiIj+GDqikDM8+U="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:+22IHz/YmVCVcdqTZjiPv05wM4Y= sha1:u2YJkK2/U0S/LPMlrKyIKPcv2bE=
Xref: csiph.com comp.lang.c:396810
scott@slp53.sl.home (Scott Lurndal) writes:
> Tim Rentsch writes:
>
>> scott@slp53.sl.home (Scott Lurndal) writes:
>>
>>> DFS writes:
>>>
>>>> On 3/4/2026 5:44 AM, Bonita Montero wrote:
>>>>
>>>> int colwidth = sprintf(cw,"%d",max) + 1;
>>>
>>> using ciel(log10(rows*columns)) performs better than snprintf
>>> in this application.
>>>
>>>
>>> $ printf '%f\n' $(( ceil(log10( 8*8)) ))
>>> 2.000000
>>
>> Using snprintf() is more correct and also more obviously correct.
>
> Yes, I had assumed the first row, first column would be zero, not one.
The value for 10 is also wrong. And 100. And 1000. etc...
By the way, I see no reason to disallow a cutoff value of 0.