Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <86jzgl65mv.fsf@linuxsc.com>
Deutsch   English   Français   Italiano  
<86jzgl65mv.fsf@linuxsc.com>

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

Path: ...!feeds.phibee-telecom.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: Challenge/exercise problem - signum() function
Date: Mon, 12 Aug 2024 09:57:28 -0700
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <86jzgl65mv.fsf@linuxsc.com>
References: <v8vlo9$2oc1v$1@dont-email.me> <v8vm2i$2oc1v$2@dont-email.me> <86y152in9n.fsf@linuxsc.com> <v9cpfm$38p3u$2@dont-email.me> <868qx193ew.fsf_-_@linuxsc.com> <v9dc06$3cajf$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Mon, 12 Aug 2024 18:57:29 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f42e4005105099d89c60a754521770ce";
	logging-data="3563735"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19FJx2WUnw2eoZKlSd/ajZf2NS2V9F03JU="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Eq6EeM5+wfIfVgdMcRQ+KcAeOqw=
	sha1:xPwiETxUQRwlkRI4li/2TFDCeX0=
Bytes: 2660

Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:

> On Mon, 12 Aug 2024 08:17:11 -0700, Tim Rentsch wrote:
>
>> Vir Campestris <vir.campestris@invalid.invalid> writes:
>>
>>> On 12/08/2024 01:43, Tim Rentsch wrote:
>>
>> [...]
>>
>>>> Also, it would be better for your understanding of C if you would
>>>> stop thinking about what is going on at the level of actual
>>>> hardware.  Doing that serves to confuse a lot more than it helps.
>>>
>>> I think I feel my ears burning!
>>
>> I'm taking that as a compliment. :)
>>
>> Also as an impetus to post a small C exercise I've been meaning
>> to put up.
>>
>> The goal is to write a C function to compute a signum() value:
>>
>>     long
>>     signum( long k ){
>>         /* should return
>>          *      -1 if k < 0
>>          *      +1 if k > 0
>>          *       0 otherwise
>>         **/
>>         /* ... */
>>         return  0; /* appropriate return value to be supplied */
>>     }
>
> [snip]
>
> Didn't we do something like this a few years ago, when someone
> complained that strcmp() did /not/ return -1, 0, or +1 on
> lessthan, equalto, or greaterthan string comparisons?

Certainly there have been similar exercises, but I don't remember
seeing this exact question.  The added restrictions make it more
difficult than it might appear.

> If I still have my "solution" around, I'll post it to followup
> the more current solutions.

Thank you, it would be good to see that.