Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Fri, 17 Dec 2021 21:00:20 -0800
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <86bl1e33tn.fsf@linuxsc.com>
References: <20210930012112$48d9@zira.vinc17.org> <87pmsqizrh.fsf@nosuchdomain.example.com> <20210930105413$d6e8@zira.vinc17.org> <87lf3ehy4v.fsf@nosuchdomain.example.com> <20211001083755$efb3@zira.vinc17.org> <86sfxbpm9d.fsf@linuxsc.com> <878rz3743a.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="6f266d79a765f44bdb30d571740e8aec"; logging-data="27914"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19hUFu8QJafwI1vWVgH/98B43/klhgjeUc="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:VKsU2QF/Ac5aEAdiCLGouI0FfV0= sha1:dsE/wi3LJlJA8+gFKpFRHGzpKek=
Xref: csiph.com comp.std.c:6398
Keith Thompson writes:
> Tim Rentsch writes:
>
>> Vincent Lefevre writes:
>
> [...]
>
>>> Shouldn't the standard by changed to make INFINITY conditionally
>>> defined (if not required to expand to a true infinity)? [...]
>>
>> To me it seems better for INFINITY to be defined as it is rather
>> than being conditionally defined. If what is needed is really an
>> infinite value, just write INFINITY and the code either works or
>> compiling it gives a diagnostic. If what is needed is just a very
>> large value, write HUGE_VAL (or HUGE_VALF or HUGE_VALL, depending)
>> and the code works whether infinite floating-point values are
>> supported or not. If it's important that infinite values be
>> supported but we don't want to risk a compilation failure, use
>> HUGE_VAL combined with an assertion
>>
>> assert( HUGE_VAL == HUGE_VAL/2 );
>>
>> Alternatively, use INFINITY only in one small .c file, and give
>> other sources a make dependency for a successful compilation
>> (with of course a -pedantic-errors option) of that .c file. I
>> don't see that having INFINITY be conditionally defined buys
>> anything, except to more or less force use of #if/#else/#endif
>> blocks in the preprocessor. I don't mind using the preprocessor
>> when there is a good reason to do so, but here I don't see one.
>
> I don't see how that's better than conditionally defining INFINITY.
It's better only in the sense that it works with the existing
C standards, and may give acceptable results in practice.