Deutsch   English   Français   Italiano  
<86iko3opxl.fsf@linuxsc.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: Suggested method for returning a string from a C program?
Date: Thu, 20 Mar 2025 05:19:02 -0700
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <86iko3opxl.fsf@linuxsc.com>
References: <vrd77d$3nvtf$2@dont-email.me> <868qp1ra5f.fsf@linuxsc.com> <vrdhok$47cb$2@dont-email.me> <20250319115550.0000676f@yahoo.com> <86jz8kpzam.fsf@linuxsc.com> <20250319221227.00001f8c@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Thu, 20 Mar 2025 13:19:03 +0100 (CET)
Injection-Info: dont-email.me; posting-host="7c01e97b5d1836204810413d59dbf156";
	logging-data="3257331"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+9APKlJPKAYwV7oJs37CmNCbeokHvIP+M="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Ewce+m0uiEky+iMV4vANEsUiSiI=
	sha1:ghjBmWAF2GHm4NS+VQcCumfs2f8=
Bytes: 2823

Michael S <already5chosen@yahoo.com> writes:

> On Wed, 19 Mar 2025 12:59:13 -0700
> Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>
>> Michael S <already5chosen@yahoo.com> writes:
>>
>>> On Wed, 19 Mar 2025 00:38:44 -0400
>>> DFS <nospam@dfs.com> wrote:
>>>
>>>> On 3/18/2025 11:07 PM, Tim Rentsch wrote:
>>>>
>>>>
>>>>> Have you thought about how large the value of 'n' can
>>>>> become inside the while() loop?
>>>>
>>>> I was too smug in my first reply.  After Keith pointed out I needed
>>>> to read from stdin, I submitted the code again and it passed some
>>>> tests but failed with 'OUTPUT LIMIT EXCEEDED' when n = 159487.
>>>>
>>>> Updating int to long worked, and now I'm bona fide!
>>>>
>>>> So thanks.
>>>
>>> What you did happens to be sufficient for a particular environment
>>> (supposedly, x86-64 Linux) used both by yourself and by the server
>>> that tests results.
>>> In more general case, 'long' is not guaranteed to handle numbers in
>>> range up to 18,997,161,173 that can happen in this test.
>>
>> The number 18997161173 is odd.  The largest value reached is three
>> times that, plus 1, which is 56991483520.
>
> Yes, my mistake.
> I only looked for maximal odd number in the sequence.  Forgot about
> even numbers.

Yes, I realized that, after the fact.

>>> Something like int64_t would be safer.
>>
>> Using unsigned long long is safer still, and easier, because there
>> is no need for hoop-jumping to print them out with printx.
>
> I explained the reason in the reply to Richard Heathfield.

Yes I saw that.  Part of my motivation for the comment is to
augment the knowledge of those who aren't sure.