Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"I'm a mean green mother from outer space" -- Audrey II, The Little Shop of Horrors


devel / comp.std.c / contradiction about the INFINITY macro

SubjectAuthor
* contradiction about the INFINITY macroVincent Lefevre
+* Re: contradiction about the INFINITY macroKeith Thompson
|`* Re: contradiction about the INFINITY macroVincent Lefevre
| +* Re: contradiction about the INFINITY macroKeith Thompson
| |`* Re: contradiction about the INFINITY macroVincent Lefevre
| | +* Re: contradiction about the INFINITY macroKeith Thompson
| | |`* Re: contradiction about the INFINITY macroVincent Lefevre
| | | `* Re: contradiction about the INFINITY macroKeith Thompson
| | |  +* Re: contradiction about the INFINITY macroGeoff Clare
| | |  |`- Re: contradiction about the INFINITY macroVincent Lefevre
| | |  `* Re: contradiction about the INFINITY macroTim Rentsch
| | |   `* Re: contradiction about the INFINITY macroKeith Thompson
| | |    `* Re: contradiction about the INFINITY macroKeith Thompson
| | |     `* Re: contradiction about the INFINITY macroVincent Lefevre
| | |      `- Re: contradiction about the INFINITY macroKeith Thompson
| | +* Re: contradiction about the INFINITY macroJakob Bohm
| | |`- Re: contradiction about the INFINITY macroKeith Thompson
| | `* Re: contradiction about the INFINITY macroTim Rentsch
| |  +* Re: contradiction about the INFINITY macroKeith Thompson
| |  |`- Re: contradiction about the INFINITY macroTim Rentsch
| |  `* Re: contradiction about the INFINITY macroVincent Lefevre
| |   +- Re: contradiction about the INFINITY macroJames Kuyper
| |   `- Re: contradiction about the INFINITY macroTim Rentsch
| `* Re: contradiction about the INFINITY macroTim Rentsch
|  `* Re: contradiction about the INFINITY macroVincent Lefevre
|   +* Re: contradiction about the INFINITY macroJames Kuyper
|   |+* Re: contradiction about the INFINITY macroKeith Thompson
|   ||+* Re: contradiction about the INFINITY macroJames Kuyper
|   |||`* Re: contradiction about the INFINITY macroKeith Thompson
|   ||| `* Re: contradiction about the INFINITY macroTim Rentsch
|   |||  `* Re: contradiction about the INFINITY macroRichard Damon
|   |||   +- Re: contradiction about the INFINITY macroKeith Thompson
|   |||   +- Re: contradiction about the INFINITY macroJames Kuyper
|   |||   `- Re: contradiction about the INFINITY macroTim Rentsch
|   ||`- Re: contradiction about the INFINITY macroTim Rentsch
|   |`* Re: contradiction about the INFINITY macroVincent Lefevre
|   | `* Re: contradiction about the INFINITY macroJames Kuyper
|   |  `* Re: contradiction about the INFINITY macroVincent Lefevre
|   |   `* Re: contradiction about the INFINITY macroJames Kuyper
|   |    `* Re: contradiction about the INFINITY macroVincent Lefevre
|   |     `* Re: contradiction about the INFINITY macroJames Kuyper
|   |      `* Re: contradiction about the INFINITY macroVincent Lefevre
|   |       `* Re: contradiction about the INFINITY macroJames Kuyper
|   |        `* Re: contradiction about the INFINITY macroVincent Lefevre
|   |         `* Re: contradiction about the INFINITY macroJames Kuyper
|   |          `* Re: contradiction about the INFINITY macroVincent Lefevre
|   |           `* Re: contradiction about the INFINITY macroJames Kuyper
|   |            `* Re: contradiction about the INFINITY macroVincent Lefevre
|   |             `* Re: contradiction about the INFINITY macroJames Kuyper
|   |              `* Re: contradiction about the INFINITY macroVincent Lefevre
|   |               `* Re: contradiction about the INFINITY macroJames Kuyper
|   |                `* Re: contradiction about the INFINITY macroVincent Lefevre
|   |                 `* Re: contradiction about the INFINITY macroJames Kuyper
|   |                  `* Re: contradiction about the INFINITY macroVincent Lefevre
|   |                   `* Re: contradiction about the INFINITY macroJames Kuyper
|   |                    +* Re: contradiction about the INFINITY macroVincent Lefevre
|   |                    |`* Re: contradiction about the INFINITY macroJames Kuyper
|   |                    | `- Re: contradiction about the INFINITY macroVincent Lefevre
|   |                    `* Re: contradiction about the INFINITY macroDerek Jones
|   |                     `- Re: contradiction about the INFINITY macroJames Kuyper
|   `* Re: contradiction about the INFINITY macroTim Rentsch
|    `* Re: contradiction about the INFINITY macroVincent Lefevre
|     `* Re: contradiction about the INFINITY macroTim Rentsch
|      +* Re: contradiction about the INFINITY macroKeith Thompson
|      |+- Re: contradiction about the INFINITY macroVincent Lefevre
|      |+- Re: contradiction about the INFINITY macroThomas Koenig
|      |`- Re: contradiction about the INFINITY macroTim Rentsch
|      `* Re: contradiction about the INFINITY macroVincent Lefevre
|       `* Re: contradiction about the INFINITY macroTim Rentsch
|        `* Re: contradiction about the INFINITY macroVincent Lefevre
|         `* Re: contradiction about the INFINITY macroJames Kuyper
|          `* Re: contradiction about the INFINITY macroVincent Lefevre
|           +- Re: contradiction about the INFINITY macroVincent Lefevre
|           `* Re: contradiction about the INFINITY macroJames Kuyper
|            `* Re: contradiction about the INFINITY macroKeith Thompson
|             +- Re: contradiction about the INFINITY macroVincent Lefevre
|             `* Re: contradiction about the INFINITY macroTim Rentsch
|              `* Re: contradiction about the INFINITY macroJames Kuyper
|               `- Re: contradiction about the INFINITY macroTim Rentsch
`- Re: contradiction about the INFINITY macroBen Bacarisse

Pages:1234
contradiction about the INFINITY macro

<20210930012112$48d9@zira.vinc17.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=343&group=comp.std.c#343

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!aioe.org!4JUmjLgy+Wx+kwpjMvj36w.user.46.165.242.75.POSTED!not-for-mail
From: vincent-...@vinc17.net (Vincent Lefevre)
Newsgroups: comp.std.c
Subject: contradiction about the INFINITY macro
Date: Thu, 30 Sep 2021 01:47:23 -0000 (UTC)
Organization: a training zoo
Message-ID: <20210930012112$48d9@zira.vinc17.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="44709"; posting-host="4JUmjLgy+Wx+kwpjMvj36w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.6.0-20210823 ("Coleburn") (Linux/5.14.0-1-amd64 (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: Vincent Lefevre - Thu, 30 Sep 2021 01:47 UTC

In ISO C99:TC3 to C17, 7.12p4:

The macro INFINITY expands to a constant expression of type float
representing positive or unsigned infinity, if available; else to a
positive constant of type float that overflows at translation time.

Consider the "else" case. It is said that INFINITY expands to a
constant and that it overflows, so that it is not in the range of
representable values of float.

But in 6.4.4p2:

Each constant shall have a type and the value of a constant shall
be in the range of representable values for its type.

which would imply that INFINITY expands to a value in the range of
representable values of float, contradicted by 7.12p4.

Same issue in the current C2x draft N2596 (7.12p7 and 6.4.4p2).

--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Re: contradiction about the INFINITY macro

<87pmsqizrh.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=344&group=comp.std.c#344

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Wed, 29 Sep 2021 19:05:38 -0700
Organization: None to speak of
Lines: 45
Message-ID: <87pmsqizrh.fsf@nosuchdomain.example.com>
References: <20210930012112$48d9@zira.vinc17.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4b075a85c80fa8b78011f466bfabf6da";
logging-data="15654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18NQ+O0BrrT59uFxq7Mu0As"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:lglA4qhEpGKwSAxhS8TEpl3WWuw=
sha1:tzqPzvdscMewq8P/Wv8fdGMDFu4=
 by: Keith Thompson - Thu, 30 Sep 2021 02:05 UTC

Vincent Lefevre <vincent-news@vinc17.net> writes:
> In ISO C99:TC3 to C17, 7.12p4:
>
> The macro INFINITY expands to a constant expression of type float
> representing positive or unsigned infinity, if available; else to a
> positive constant of type float that overflows at translation time.
>
> Consider the "else" case. It is said that INFINITY expands to a
> constant and that it overflows, so that it is not in the range of
> representable values of float.
>
> But in 6.4.4p2:
>
> Each constant shall have a type and the value of a constant shall
> be in the range of representable values for its type.
>
> which would imply that INFINITY expands to a value in the range of
> representable values of float, contradicted by 7.12p4.
>
> Same issue in the current C2x draft N2596 (7.12p7 and 6.4.4p2).

6.4.4p2 is a constraint. It doesn't make it impossible to write code
that violates that constraint.

If I understand correctly, it means that if an infinite value is not
available, then a program that refers to the INFINITY macro (in a
context where it's treated as a floating-point expression) violates that
constraint, resulting in a required diagnostic.

In fact I wrote the previous paragraph before I read the footnote on the
definition of INFINITY (N1570 7.12p4, footnote 229):

In this case, using INFINITY will violate the constraint in 6.4.4
and thus require a diagnostic.

There is no contradiction.

(I wonder if it would have been more useful to require that INFINITY not
be defined unless it can be defined as an actual infinity, but I haven't
given it a lot of thought.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: contradiction about the INFINITY macro

<87a6jun6s8.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=345&group=comp.std.c#345

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Thu, 30 Sep 2021 03:20:23 +0100
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <87a6jun6s8.fsf@bsb.me.uk>
References: <20210930012112$48d9@zira.vinc17.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="50d1fb071442832dba5b87e100f83a1a";
logging-data="14035"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+ZV6hFyQ24qsBld24ZOmH5NO2p5zpveM="
Cancel-Lock: sha1:NmP6EeV+BsqH/Oreb8t6tO6aWTg=
sha1:H2nPsrYGcHldJtVhqkbB9wOZsAU=
X-BSB-Auth: 1.60262bb36d5e89f07070.20210930032023BST.87a6jun6s8.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 30 Sep 2021 02:20 UTC

Vincent Lefevre <vincent-news@vinc17.net> writes:

> In ISO C99:TC3 to C17, 7.12p4:
>
> The macro INFINITY expands to a constant expression of type float
> representing positive or unsigned infinity, if available; else to a
> positive constant of type float that overflows at translation time.
>
> Consider the "else" case. It is said that INFINITY expands to a
> constant and that it overflows, so that it is not in the range of
> representable values of float.
>
> But in 6.4.4p2:
>
> Each constant shall have a type and the value of a constant shall
> be in the range of representable values for its type.
>
> which would imply that INFINITY expands to a value in the range of
> representable values of float, contradicted by 7.12p4.

Right. But there is footnote that clarifies matters:

"In this case, using INFINITY will violate the constraint in 6.4.4 and
thus require a diagnostic."

so any program using INFINITY has undefined behaviour because the intent
is to violate 6.4.4. I agree that there should be a better way to
specify it, but expanding to a constant that violates the constraints on
such constants is clumsy but reasonably clear.

--
Ben.

Re: contradiction about the INFINITY macro

<20210930105413$d6e8@zira.vinc17.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=346&group=comp.std.c#346

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!aioe.org!4JUmjLgy+Wx+kwpjMvj36w.user.46.165.242.75.POSTED!not-for-mail
From: vincent-...@vinc17.net (Vincent Lefevre)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Thu, 30 Sep 2021 11:24:08 -0000 (UTC)
Organization: a training zoo
Message-ID: <20210930105413$d6e8@zira.vinc17.org>
References: <20210930012112$48d9@zira.vinc17.org> <87pmsqizrh.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="20336"; posting-host="4JUmjLgy+Wx+kwpjMvj36w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.6.0-20210823 ("Coleburn") (Linux/5.14.0-1-amd64 (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: Vincent Lefevre - Thu, 30 Sep 2021 11:24 UTC

In article <87pmsqizrh.fsf@nosuchdomain.example.com>,
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> Vincent Lefevre <vincent-news@vinc17.net> writes:
> > In ISO C99:TC3 to C17, 7.12p4:
> >
> > The macro INFINITY expands to a constant expression of type float
> > representing positive or unsigned infinity, if available; else to a
> > positive constant of type float that overflows at translation time.
> >
> > Consider the "else" case. It is said that INFINITY expands to a
> > constant and that it overflows, so that it is not in the range of
> > representable values of float.
> >
> > But in 6.4.4p2:
> >
> > Each constant shall have a type and the value of a constant shall
> > be in the range of representable values for its type.
> >
> > which would imply that INFINITY expands to a value in the range of
> > representable values of float, contradicted by 7.12p4.
> >
> > Same issue in the current C2x draft N2596 (7.12p7 and 6.4.4p2).

> 6.4.4p2 is a constraint. It doesn't make it impossible to write code
> that violates that constraint.

Yes, but the issue here is that the standard mandates the implementation
to violate a constraint, which is rather different from the case where a
user writes buggy code.

> If I understand correctly, it means that if an infinite value is not
> available, then a program that refers to the INFINITY macro (in a
> context where it's treated as a floating-point expression) violates that
> constraint, resulting in a required diagnostic.

I think the consequence is more than a diagnostic (which may yield a
compilation failure in practice, BTW): AFAIK, the standard does not
give a particular definition for "overflows at translation time",
which would make it undefined behavior as usual for overflows.

--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Re: contradiction about the INFINITY macro

<87lf3ehy4v.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=347&group=comp.std.c#347

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Thu, 30 Sep 2021 08:38:24 -0700
Organization: None to speak of
Lines: 85
Message-ID: <87lf3ehy4v.fsf@nosuchdomain.example.com>
References: <20210930012112$48d9@zira.vinc17.org>
<87pmsqizrh.fsf@nosuchdomain.example.com>
<20210930105413$d6e8@zira.vinc17.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4b075a85c80fa8b78011f466bfabf6da";
logging-data="23273"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1sT+KX1bANSgUZrstWdJT"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:Mzl65+HsOg5jrYWq6Kf65Szj6bo=
sha1:c4zyby/gwrY9Ar63rH5u4p7QRXw=
 by: Keith Thompson - Thu, 30 Sep 2021 15:38 UTC

Vincent Lefevre <vincent-news@vinc17.net> writes:
> In article <87pmsqizrh.fsf@nosuchdomain.example.com>,
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> Vincent Lefevre <vincent-news@vinc17.net> writes:
>> > In ISO C99:TC3 to C17, 7.12p4:
>> >
>> > The macro INFINITY expands to a constant expression of type float
>> > representing positive or unsigned infinity, if available; else to a
>> > positive constant of type float that overflows at translation time.
>> >
>> > Consider the "else" case. It is said that INFINITY expands to a
>> > constant and that it overflows, so that it is not in the range of
>> > representable values of float.
>> >
>> > But in 6.4.4p2:
>> >
>> > Each constant shall have a type and the value of a constant shall
>> > be in the range of representable values for its type.
>> >
>> > which would imply that INFINITY expands to a value in the range of
>> > representable values of float, contradicted by 7.12p4.
>> >
>> > Same issue in the current C2x draft N2596 (7.12p7 and 6.4.4p2).
>
>> 6.4.4p2 is a constraint. It doesn't make it impossible to write code
>> that violates that constraint.
>
> Yes, but the issue here is that the standard mandates the implementation
> to violate a constraint, which is rather different from the case where a
> user writes buggy code.

No, it doesn't force the implementation to violate a constraint. It
says that a *program* that uses the INFINITY macro violates a constraint
(if the implementation doesn't support infinities).

Constraints apply to programs, not to implementations.

It means that if a program assumes that INFINITY is meaningful, and it's
compiled for a target system where it isn't, a diagnostic is guaranteed.
And again, it might have made more sense to say that INFINITY is not
defined for such implementations (as is done for the NAN macro), but
perhaps there was existing practice.

Here's what the C99 Rationale says:

What is INFINITY on machines that do not support infinity? It should
be defined along the lines of: #define INFINITY 9e99999f, where
there are enough 9s in the exponent so that the value is too large
to represent as a float, hence, violates the constraint of 6.4.4
Constants. In addition, the number classification macro FP_INFINITE
should not be defined. That allows an application to test for the
existance of FP_INFINITE as a safe way to determine if infinity is
supported; this is the feature test macro for support for infinity.

The problem with this is that the standard itself doesn't say that
FP_INFINITE is defined conditionally.

>> If I understand correctly, it means that if an infinite value is not
>> available, then a program that refers to the INFINITY macro (in a
>> context where it's treated as a floating-point expression) violates that
>> constraint, resulting in a required diagnostic.
>
> I think the consequence is more than a diagnostic (which may yield a
> compilation failure in practice, BTW): AFAIK, the standard does not
> give a particular definition for "overflows at translation time",
> which would make it undefined behavior as usual for overflows.

The meaning seems clear enough to me. It's a floating constant whose
mathematical value is outside the range of float, such as 9e99999f.
And yes, evaluating it (if the mandatory diagnostic does not cause
compilation to fail) causes undefined behavior. I think the intent is
that a portable program should check whether infinities are supported
before trying to evaluate INFINITY, but that intent is not well
reflected in the standard.

I don't think I have access to an implementation that doesn't support
infinities, so I don't know how this is handled in practice. Given the
near universal adoption of IEEE floating-point, it's probably reasonably
safe to assume that infinities are supported unless your program needs
to be painfully portable.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: contradiction about the INFINITY macro

<20211001083755$efb3@zira.vinc17.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=348&group=comp.std.c#348

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!aioe.org!4JUmjLgy+Wx+kwpjMvj36w.user.46.165.242.75.POSTED!not-for-mail
From: vincent-...@vinc17.net (Vincent Lefevre)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Fri, 1 Oct 2021 09:05:38 -0000 (UTC)
Organization: a training zoo
Message-ID: <20211001083755$efb3@zira.vinc17.org>
References: <20210930012112$48d9@zira.vinc17.org> <87pmsqizrh.fsf@nosuchdomain.example.com> <20210930105413$d6e8@zira.vinc17.org> <87lf3ehy4v.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="26765"; posting-host="4JUmjLgy+Wx+kwpjMvj36w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.6.0-20210823 ("Coleburn") (Linux/5.14.0-1-amd64 (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: Vincent Lefevre - Fri, 1 Oct 2021 09:05 UTC

In article <87lf3ehy4v.fsf@nosuchdomain.example.com>,
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> No, it doesn't force the implementation to violate a constraint. It
> says that a *program* that uses the INFINITY macro violates a constraint
> (if the implementation doesn't support infinities).

Then this means that the C standard defines something the user must
not use (except when __STDC_IEC_559__ is defined, as in this case,
INFINITY is guaranteed to expand to the true infinity).

> Constraints apply to programs, not to implementations.

This is related, as programs will be transformed by an implementation.

> It means that if a program assumes that INFINITY is meaningful, and it's
> compiled for a target system where it isn't, a diagnostic is guaranteed.
> And again, it might have made more sense to say that INFINITY is not
> defined for such implementations (as is done for the NAN macro), but
> perhaps there was existing practice.

Yes, currently there is no way of fallback (without things like
autoconf tests).

Shouldn't the standard by changed to make INFINITY conditionally
defined (if not required to expand to a true infinity)?
This should not break existing programs.

> Here's what the C99 Rationale says:

> What is INFINITY on machines that do not support infinity? It should
> be defined along the lines of: #define INFINITY 9e99999f, where
> there are enough 9s in the exponent so that the value is too large
> to represent as a float, hence, violates the constraint of 6.4.4
> Constants. In addition, the number classification macro FP_INFINITE
> should not be defined. That allows an application to test for the
> existance of FP_INFINITE as a safe way to determine if infinity is
> supported; this is the feature test macro for support for infinity.

> The problem with this is that the standard itself doesn't say that
> FP_INFINITE is defined conditionally.

Even if FP_INFINITE could be defined conditionally, this would not
imply that INFINITY is usable, since for instance, long double may
have an infinity but not float.

--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Re: contradiction about the INFINITY macro

<877dewimc9.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=349&group=comp.std.c#349

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Fri, 01 Oct 2021 12:20:06 -0700
Organization: None to speak of
Lines: 33
Message-ID: <877dewimc9.fsf@nosuchdomain.example.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>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="13acd1fe4bff95bcb7ffb2395063c869";
logging-data="10779"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/MCjsVdzjSvPk+wuOOPsvS"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:S2Rwa4l0n5gCUg4tMczRZf2JA5M=
sha1:PchTualhAKmyjeJ51csRYFd5KRc=
 by: Keith Thompson - Fri, 1 Oct 2021 19:20 UTC

Vincent Lefevre <vincent-news@vinc17.net> writes:
> In article <87lf3ehy4v.fsf@nosuchdomain.example.com>,
[...]
> Shouldn't the standard by changed to make INFINITY conditionally
> defined (if not required to expand to a true infinity)?
> This should not break existing programs.

I agree. NAN is conditionally defined "if and only if the
implementation supports quiet NaNs for the float type". I have no
idea why the same wasn't done for INFINITY -- unless, as I mentioned
upthread, there was existing practice. INFINITY was introduced
in C99. Perhaps there were pre-C99 implementations that defined
INFINITY as an extension in the way that's now specified in the
standard. That's just speculation, and I still think making it
conditional would have made more sense.

[...]

> Even if FP_INFINITE could be defined conditionally, this would not
> imply that INFINITY is usable, since for instance, long double may
> have an infinity but not float.

The standard only defines INFINITY and NAN for type float. I think the
implication is that it assumes either all floating types have NaNs
and/or infinities, or none do. That might be a valid assumption. (The
Alpha supports both VAX and IEEE floating-point, and I don't think VAX
FP supports infinities or NaNs, but I don't think an implementation
would use, for example, VAX FP for float and IEEE for double.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: contradiction about the INFINITY macro

<58udnbOX8PAx6Mr8nZ2dnUU78aHNnZ2d@giganews.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=350&group=comp.std.c#350

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!buffer2.nntp.ams1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 01 Oct 2021 15:55:08 -0500
Subject: Re: contradiction about the INFINITY macro
Newsgroups: comp.std.c
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>
From: jb-use...@wisemo.com.invalid (Jakob Bohm)
Organization: WiseMo A/S
Date: Fri, 1 Oct 2021 22:55:07 +0200
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:4.8) Goanna/20210817
Interlink/52.9.7899
MIME-Version: 1.0
In-Reply-To: <20211001083755$efb3@zira.vinc17.org>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Message-ID: <58udnbOX8PAx6Mr8nZ2dnUU78aHNnZ2d@giganews.com>
Lines: 63
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-aFmqIgtcgfOe4jhWFkk2DWoONooJBFlEgYDQUkTPRk7kzJrNfIko7LBrRd0A0TDG11qw7smb/YgyCN8!OzU37KXeXQTIEA/Z6pQsuZbqeM9KErrYO8JChn7vUMpV133xGY7PZASkgNleS+mi2mdOsdOiQIc=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 4148
 by: Jakob Bohm - Fri, 1 Oct 2021 20:55 UTC

On 2021-10-01 11:05, Vincent Lefevre wrote:
> In article <87lf3ehy4v.fsf@nosuchdomain.example.com>,
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>
>> No, it doesn't force the implementation to violate a constraint. It
>> says that a *program* that uses the INFINITY macro violates a constraint
>> (if the implementation doesn't support infinities).
>
> Then this means that the C standard defines something the user must
> not use (except when __STDC_IEC_559__ is defined, as in this case,
> INFINITY is guaranteed to expand to the true infinity).
>
>> Constraints apply to programs, not to implementations.
>
> This is related, as programs will be transformed by an implementation.
>
>> It means that if a program assumes that INFINITY is meaningful, and it's
>> compiled for a target system where it isn't, a diagnostic is guaranteed.
>> And again, it might have made more sense to say that INFINITY is not
>> defined for such implementations (as is done for the NAN macro), but
>> perhaps there was existing practice.
>
> Yes, currently there is no way of fallback (without things like
> autoconf tests).
>
> Shouldn't the standard by changed to make INFINITY conditionally
> defined (if not required to expand to a true infinity)?
> This should not break existing programs.

The fallback is to test for defined(FP_INFINITE), see below.

>
>> Here's what the C99 Rationale says:
>
>> What is INFINITY on machines that do not support infinity? It should
>> be defined along the lines of: #define INFINITY 9e99999f, where
>> there are enough 9s in the exponent so that the value is too large
>> to represent as a float, hence, violates the constraint of 6.4.4
>> Constants. In addition, the number classification macro FP_INFINITE
>> should not be defined. That allows an application to test for the
>> existance of FP_INFINITE as a safe way to determine if infinity is
>> supported; this is the feature test macro for support for infinity.
>
>> The problem with this is that the standard itself doesn't say that
>> FP_INFINITE is defined conditionally.
>
> Even if FP_INFINITE could be defined conditionally, this would not
> imply that INFINITY is usable, since for instance, long double may
> have an infinity but not float.
>

I don't know if there is a set of similar macros for double and long
double types buried somewhere in the standard.

Enjoy

Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S. https://www.wisemo.com
Transformervej 29, 2860 Søborg, Denmark. Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded

Re: contradiction about the INFINITY macro

<87tui0h1xq.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=351&group=comp.std.c#351

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Fri, 01 Oct 2021 14:26:09 -0700
Organization: None to speak of
Lines: 73
Message-ID: <87tui0h1xq.fsf@nosuchdomain.example.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>
<58udnbOX8PAx6Mr8nZ2dnUU78aHNnZ2d@giganews.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="13acd1fe4bff95bcb7ffb2395063c869";
logging-data="20569"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19t9GX1MB8sZQNTmw3lsH30"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:4JjnZBKE+QGlrrXkrHWNsgqwhFc=
sha1:JJhGnQo8TKgUf7vO6U9RmWpZ8+A=
 by: Keith Thompson - Fri, 1 Oct 2021 21:26 UTC

Jakob Bohm <jb-usenet@wisemo.com.invalid> writes:
> On 2021-10-01 11:05, Vincent Lefevre wrote:
>> In article <87lf3ehy4v.fsf@nosuchdomain.example.com>,
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>
>>> No, it doesn't force the implementation to violate a constraint. It
>>> says that a *program* that uses the INFINITY macro violates a constraint
>>> (if the implementation doesn't support infinities).
>> Then this means that the C standard defines something the user must
>> not use (except when __STDC_IEC_559__ is defined, as in this case,
>> INFINITY is guaranteed to expand to the true infinity).
>>
>>> Constraints apply to programs, not to implementations.
>> This is related, as programs will be transformed by an
>> implementation.
>>
>>> It means that if a program assumes that INFINITY is meaningful, and it's
>>> compiled for a target system where it isn't, a diagnostic is guaranteed.
>>> And again, it might have made more sense to say that INFINITY is not
>>> defined for such implementations (as is done for the NAN macro), but
>>> perhaps there was existing practice.
>> Yes, currently there is no way of fallback (without things like
>> autoconf tests).
>> Shouldn't the standard by changed to make INFINITY conditionally
>> defined (if not required to expand to a true infinity)?
>> This should not break existing programs.
>
> The fallback is to test for defined(FP_INFINITE), see below.
>
>>
>>> Here's what the C99 Rationale says:
>>
>>> What is INFINITY on machines that do not support infinity? It should
>>> be defined along the lines of: #define INFINITY 9e99999f, where
>>> there are enough 9s in the exponent so that the value is too large
>>> to represent as a float, hence, violates the constraint of 6.4.4
>>> Constants. In addition, the number classification macro FP_INFINITE
>>> should not be defined. That allows an application to test for the
>>> existance of FP_INFINITE as a safe way to determine if infinity is
>>> supported; this is the feature test macro for support for infinity.
>>
>>> The problem with this is that the standard itself doesn't say that
>>> FP_INFINITE is defined conditionally.
>> Even if FP_INFINITE could be defined conditionally, this would not
>> imply that INFINITY is usable, since for instance, long double may
>> have an infinity but not float.
>>
>
> I don't know if there is a set of similar macros for double and long
> double types buried somewhere in the standard.

The INFINITY and NAN macros are defined only for float. I think the
assumption is that either all floating-point types support infinities,
or none do, and likewise for NaNs. On the other hand, fpclassify() is a
macro that can be applied to an expression of any floating-point type.

The problem, as I said, is that the standard doesn't say that
FP_INFINITE is conditionally defined. Since they're specified in the
same section that explicitly says that NAN is conditionally defined, I
think the only reasonable reading of the standard's wording is that
FP_INFINITE is defined whether infinities are supported or not.
If they're not, it just means that fpclassify() will never return
FP_INFINITE and isinf() always returns 0.

The author(s) of the Rationale obviously *thought* that FP_INFINITE is
conditionally defined. They were mistaken. The Rationale itself makes
it clear that the Standard, not the Rationale, is what defines the
language.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: contradiction about the INFINITY macro

<20211004092110$b3e8@zira.vinc17.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=352&group=comp.std.c#352

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!i2pn.org!aioe.org!4JUmjLgy+Wx+kwpjMvj36w.user.46.165.242.75.POSTED!not-for-mail
From: vincent-...@vinc17.net (Vincent Lefevre)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Mon, 4 Oct 2021 09:26:19 -0000 (UTC)
Organization: a training zoo
Message-ID: <20211004092110$b3e8@zira.vinc17.org>
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> <877dewimc9.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="51181"; posting-host="4JUmjLgy+Wx+kwpjMvj36w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.6.0-20210823 ("Coleburn") (Linux/5.14.0-1-amd64 (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: Vincent Lefevre - Mon, 4 Oct 2021 09:26 UTC

In article <877dewimc9.fsf@nosuchdomain.example.com>,
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> Vincent Lefevre <vincent-news@vinc17.net> writes:
> > In article <87lf3ehy4v.fsf@nosuchdomain.example.com>,
> > Even if FP_INFINITE could be defined conditionally, this would not
> > imply that INFINITY is usable, since for instance, long double may
> > have an infinity but not float.

> The standard only defines INFINITY and NAN for type float. I think the
> implication is that it assumes either all floating types have NaNs
> and/or infinities, or none do. That might be a valid assumption.

But the standard doesn't say that explicitly. It even just says
"if and only if the implementation supports quiet NaNs for the
float type". If the intent were to have NaN support for all the
FP types or none, why doesn't it say "... for the floating types"
instead of "... for the float type"?

--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Re: contradiction about the INFINITY macro

<87r1d0g0dh.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=353&group=comp.std.c#353

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Mon, 04 Oct 2021 10:34:18 -0700
Organization: None to speak of
Lines: 32
Message-ID: <87r1d0g0dh.fsf@nosuchdomain.example.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>
<877dewimc9.fsf@nosuchdomain.example.com>
<20211004092110$b3e8@zira.vinc17.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="f039da7ec9ded39f2ed1a75f27d21830";
logging-data="21882"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+DAN+fFPRsyh8eeP018s17"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:il36EtCYZqTseOrcASECUzcgijs=
sha1:L2M4ZkYxoDRSycPk8o/Udht0ClU=
 by: Keith Thompson - Mon, 4 Oct 2021 17:34 UTC

Vincent Lefevre <vincent-news@vinc17.net> writes:
> In article <877dewimc9.fsf@nosuchdomain.example.com>,
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>
>> Vincent Lefevre <vincent-news@vinc17.net> writes:
>> > In article <87lf3ehy4v.fsf@nosuchdomain.example.com>,
>> > Even if FP_INFINITE could be defined conditionally, this would not
>> > imply that INFINITY is usable, since for instance, long double may
>> > have an infinity but not float.
>
>> The standard only defines INFINITY and NAN for type float. I think the
>> implication is that it assumes either all floating types have NaNs
>> and/or infinities, or none do. That might be a valid assumption.
>
> But the standard doesn't say that explicitly. It even just says
> "if and only if the implementation supports quiet NaNs for the
> float type". If the intent were to have NaN support for all the
> FP types or none, why doesn't it say "... for the floating types"
> instead of "... for the float type"?

Since the NAN macro is of type float (if it's define), it only makes
sense to define it that way. Presumably if an implementation had
NaN for float but not for double, it would define NAN.

IMHO it would have been better if the assumption that all floating
types behave similarly had been stated explicitly, and perhaps if there
were three NAN macros for the three floating-point types.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: contradiction about the INFINITY macro

<ieut2i-07m.ln1@ID-313840.user.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=355&group=comp.std.c#355

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: geo...@clare.See-My-Signature.invalid (Geoff Clare)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Tue, 5 Oct 2021 13:53:06 +0100
Lines: 14
Message-ID: <ieut2i-07m.ln1@ID-313840.user.individual.net>
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>
<877dewimc9.fsf@nosuchdomain.example.com>
<20211004092110$b3e8@zira.vinc17.org>
<87r1d0g0dh.fsf@nosuchdomain.example.com>
Reply-To: netnews@gclare.org.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net OMYZwK61MU5SOyVzw5l02wGV/qzjmfnccmWwz7xIosdzieW+Pm
X-Orig-Path: ID-313840.user.individual.net!not-for-mail
Cancel-Lock: sha1:vmMi97nfpYB8ENHXtaQQZanzzyQ=
User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a
git.gnome.org/pan2)
 by: Geoff Clare - Tue, 5 Oct 2021 12:53 UTC

Keith Thompson wrote:

> Presumably if an implementation had
> NaN for float but not for double, it would define NAN.
>
> IMHO it would have been better if the assumption that all floating
> types behave similarly had been stated explicitly, and perhaps if there
> were three NAN macros for the three floating-point types.

NaN support for each floating type can be queried, and a NaN
obtained if supported, by calling nanf(), nan(), and nanl().

--
Geoff Clare <netnews@gclare.org.uk>

Re: contradiction about the INFINITY macro

<20211006000739$eba9@zira.vinc17.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=356&group=comp.std.c#356

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!news.neodome.net!news.mixmin.net!aioe.org!4JUmjLgy+Wx+kwpjMvj36w.user.46.165.242.75.POSTED!not-for-mail
From: vincent-...@vinc17.net (Vincent Lefevre)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Wed, 6 Oct 2021 00:12:38 -0000 (UTC)
Organization: a training zoo
Message-ID: <20211006000739$eba9@zira.vinc17.org>
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> <877dewimc9.fsf@nosuchdomain.example.com> <20211004092110$b3e8@zira.vinc17.org> <87r1d0g0dh.fsf@nosuchdomain.example.com> <ieut2i-07m.ln1@ID-313840.user.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="34875"; posting-host="4JUmjLgy+Wx+kwpjMvj36w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.6.0-20210823 ("Coleburn") (Linux/5.14.0-1-amd64 (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: Vincent Lefevre - Wed, 6 Oct 2021 00:12 UTC

In article <ieut2i-07m.ln1@ID-313840.user.individual.net>,
Geoff Clare <geoff@clare.see-my-signature.invalid> wrote:

> NaN support for each floating type can be queried, and a NaN
> obtained if supported, by calling nanf(), nan(), and nanl().

But they are not required to be constant expressions, while
the NAN macro expands to a constant expression.

--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Re: contradiction about the INFINITY macro

<861r4xq6a8.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=357&group=comp.std.c#357

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Thu, 07 Oct 2021 07:05:35 -0700
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <861r4xq6a8.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> <877dewimc9.fsf@nosuchdomain.example.com> <20211004092110$b3e8@zira.vinc17.org> <87r1d0g0dh.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="9374937631a63b2b305129710c17edd9";
logging-data="31731"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yZsoi/BnF1LXmn9DSgA/0zF0nWm91fjc="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:0gtwFVHRqOaGd5xGXczt2vDDOsY=
sha1:XXW5LSjvP7NG4FiWyC7+Wgd9k5A=
 by: Tim Rentsch - Thu, 7 Oct 2021 14:05 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Vincent Lefevre <vincent-news@vinc17.net> writes:
>
>> In article <877dewimc9.fsf@nosuchdomain.example.com>,
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>
>>> Vincent Lefevre <vincent-news@vinc17.net> writes:
>>>
>>>> In article <87lf3ehy4v.fsf@nosuchdomain.example.com>,
>>>> Even if FP_INFINITE could be defined conditionally, this would
>>>> not imply that INFINITY is usable, since for instance, long
>>>> double may have an infinity but not float.
>>>
>>> The standard only defines INFINITY and NAN for type float. I
>>> think the implication is that it assumes either all floating types
>>> have NaNs and/or infinities, or none do. That might be a valid
>>> assumption.
>>
>> But the standard doesn't say that explicitly. It even just says
>> "if and only if the implementation supports quiet NaNs for the
>> float type". If the intent were to have NaN support for all the
>> FP types or none, why doesn't it say "... for the floating types"
>> instead of "... for the float type"?
>
> Since the NAN macro is of type float (if it's define), it only makes
> sense to define it that way. Presumably if an implementation had
> NaN for float but not for double, it would define NAN.

If float has a NaN then so do double and long double, because of
6.2.5 paragraph 10. Similarly for infinity (or infinities).

Re: contradiction about the INFINITY macro

<87czog7uso.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=358&group=comp.std.c#358

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Thu, 07 Oct 2021 07:51:03 -0700
Organization: None to speak of
Lines: 43
Message-ID: <87czog7uso.fsf@nosuchdomain.example.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>
<877dewimc9.fsf@nosuchdomain.example.com>
<20211004092110$b3e8@zira.vinc17.org>
<87r1d0g0dh.fsf@nosuchdomain.example.com> <861r4xq6a8.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="0101718fcd2a42c8d4c22baec500ecab";
logging-data="11727"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+ZACt509IKwMeBhHvx2hN"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:iurxdBqQqWnx7AiAflpuKTx86fI=
sha1:JkLBCv9DWxSkMPHRvdBRY3EmpAQ=
 by: Keith Thompson - Thu, 7 Oct 2021 14:51 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Vincent Lefevre <vincent-news@vinc17.net> writes:
>>> In article <877dewimc9.fsf@nosuchdomain.example.com>,
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>>> Vincent Lefevre <vincent-news@vinc17.net> writes:
>>>>
>>>>> In article <87lf3ehy4v.fsf@nosuchdomain.example.com>,
>>>>> Even if FP_INFINITE could be defined conditionally, this would
>>>>> not imply that INFINITY is usable, since for instance, long
>>>>> double may have an infinity but not float.
>>>>
>>>> The standard only defines INFINITY and NAN for type float. I
>>>> think the implication is that it assumes either all floating types
>>>> have NaNs and/or infinities, or none do. That might be a valid
>>>> assumption.
>>>
>>> But the standard doesn't say that explicitly. It even just says
>>> "if and only if the implementation supports quiet NaNs for the
>>> float type". If the intent were to have NaN support for all the
>>> FP types or none, why doesn't it say "... for the floating types"
>>> instead of "... for the float type"?
>>
>> Since the NAN macro is of type float (if it's define), it only makes
>> sense to define it that way. Presumably if an implementation had
>> NaN for float but not for double, it would define NAN.
>
> If float has a NaN then so do double and long double, because of
> 6.2.5 paragraph 10. Similarly for infinity (or infinities).

Agreed. 6.2.5p10 says:

There are three real floating types, designated as float, double,
and long double. The set of values of the type float is a subset of
the set of values of the type double; the set of values of the type
double is a subset of the set of values of the type long double.

(No need to make everyone look it up.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: contradiction about the INFINITY macro

<86wnmoov7c.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=359&group=comp.std.c#359

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Fri, 08 Oct 2021 00:02:31 -0700
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <86wnmoov7c.fsf@linuxsc.com>
References: <20210930012112$48d9@zira.vinc17.org> <87pmsqizrh.fsf@nosuchdomain.example.com> <20210930105413$d6e8@zira.vinc17.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="00819d90e026a0feda9a088fdad5956f";
logging-data="29989"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Cd6Wy1iQX7V7TumVUY0FxRjfw2+yX/ZY="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:1ozefBDM6+54n19AKdFQ8Rfklug=
sha1:iXunyyE5Hflx3yk0ztVUDzatZtI=
 by: Tim Rentsch - Fri, 8 Oct 2021 07:02 UTC

Vincent Lefevre <vincent-news@vinc17.net> writes:

> In article <87pmsqizrh.fsf@nosuchdomain.example.com>,
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

[.. use of the INFINITY macro in an implementation that does not
have a float value for infinity..]

>> If I understand correctly, it means that if an infinite value is
>> not available, then a program that refers to the INFINITY macro (in
>> a context where it's treated as a floating-point expression)
>> violates that constraint, resulting in a required diagnostic.
>
> I think the consequence is more than a diagnostic (which may yield
> a compilation failure in practice, BTW): AFAIK, the standard does
> not give a particular definition for "overflows at translation
> time", which would make it undefined behavior as usual for
> overflows.

The compound phrase does not need defining because its relevant
constituent elements are defined in the C standard. The word
"overflows" is defined for floating point types in 7.12.1
paragraph 5

A floating result overflows if the magnitude of the
mathematical result is finite but so large that the
mathematical result cannot be represented without
extraordinary roundoff error in an object of the specified
type. [...]

The word "translation" is defined in detail in section 5.1.1.
The compound phrase "overflows at translation time" is simply a
combination of these defined terms under normal rules of English
usage.

Moreover, the C standard is quite clear that violating a
constraint must evoke a diagnostic even if there is also
undefined behavior. Section 5.1.1.3 paragraph 1 says this:

A conforming implementation shall produce at least one
diagnostic message (identified in an implementation-defined
manner) if a preprocessing translation unit or translation
unit contains a violation of any syntax rule or constraint,
even if the behavior is also explicitly specified as
undefined or implementation-defined. [...]

What occurs is defined behavior and (for implementations that do
not have the needed value for infinity) violates a constraint.
A diagnostic must be produced.

Re: contradiction about the INFINITY macro

<86sfxbpm9d.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=361&group=comp.std.c#361

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Fri, 08 Oct 2021 08:30:22 -0700
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <86sfxbpm9d.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>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="00819d90e026a0feda9a088fdad5956f";
logging-data="10339"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ouiiSTRxfoTTb1woTZib1ZZT5K8+oaVo="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:rRAnrm3JHyIpwefveDFH2HRB9Fc=
sha1:B+SM0lzVhuCZWbnuM9o+VoeU/0Y=
 by: Tim Rentsch - Fri, 8 Oct 2021 15:30 UTC

Vincent Lefevre <vincent-news@vinc17.net> writes:

> In article <87lf3ehy4v.fsf@nosuchdomain.example.com>,
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

[...]

>> It means that if a program assumes that INFINITY is meaningful, and
>> it's compiled for a target system where it isn't, a diagnostic is
>> guaranteed. And again, it might have made more sense to say that
>> INFINITY is not defined for such implementations (as is done for
>> the NAN macro), but perhaps there was existing practice.
>
> Yes, currently there is no way of fallback (without things like
> autoconf tests).
>
> 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.

Re: contradiction about the INFINITY macro

<878rz3743a.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=362&group=comp.std.c#362

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Fri, 08 Oct 2021 11:40:09 -0700
Organization: None to speak of
Lines: 39
Message-ID: <878rz3743a.fsf@nosuchdomain.example.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>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="41139519b557a828e82b1a9dc12922fd";
logging-data="24327"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cZehLj9NZ9HIDdJoGw/I2"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:Pw/w+F3lRCGRKBpX18+8W9DpTcM=
sha1:joKgv7eQwI/wUjImidRL4BHPCkg=
 by: Keith Thompson - Fri, 8 Oct 2021 18:40 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Vincent Lefevre <vincent-news@vinc17.net> 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.

If you really need an infinite value, just write INFINITY and the code
either works or compiling it gives a *clearer* diagnostic for the
undeclared identifier.

If you need to test whether infinities are supported, #ifdef INFINITY is
a lot clearer than assert( HUGE_VAL == HUGE_VAL/2 ).

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: contradiction about the INFINITY macro

<874k9r7419.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=363&group=comp.std.c#363

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Fri, 08 Oct 2021 11:41:22 -0700
Organization: None to speak of
Lines: 47
Message-ID: <874k9r7419.fsf@nosuchdomain.example.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>
<877dewimc9.fsf@nosuchdomain.example.com>
<20211004092110$b3e8@zira.vinc17.org>
<87r1d0g0dh.fsf@nosuchdomain.example.com> <861r4xq6a8.fsf@linuxsc.com>
<87czog7uso.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="41139519b557a828e82b1a9dc12922fd";
logging-data="24327"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wY1OEU9sZljSR2oZHSYU3"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:bVPzabiR22uh3rWo7Xh46UMU5UE=
sha1:bYWA6v/0XQQ/OCkwUwq4wC9sTD0=
 by: Keith Thompson - Fri, 8 Oct 2021 18:41 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>> Vincent Lefevre <vincent-news@vinc17.net> writes:
>>>> In article <877dewimc9.fsf@nosuchdomain.example.com>,
>>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>>>> Vincent Lefevre <vincent-news@vinc17.net> writes:
>>>>>
>>>>>> In article <87lf3ehy4v.fsf@nosuchdomain.example.com>,
>>>>>> Even if FP_INFINITE could be defined conditionally, this would
>>>>>> not imply that INFINITY is usable, since for instance, long
>>>>>> double may have an infinity but not float.
>>>>>
>>>>> The standard only defines INFINITY and NAN for type float. I
>>>>> think the implication is that it assumes either all floating types
>>>>> have NaNs and/or infinities, or none do. That might be a valid
>>>>> assumption.
>>>>
>>>> But the standard doesn't say that explicitly. It even just says
>>>> "if and only if the implementation supports quiet NaNs for the
>>>> float type". If the intent were to have NaN support for all the
>>>> FP types or none, why doesn't it say "... for the floating types"
>>>> instead of "... for the float type"?
>>>
>>> Since the NAN macro is of type float (if it's define), it only makes
>>> sense to define it that way. Presumably if an implementation had
>>> NaN for float but not for double, it would define NAN.
>>
>> If float has a NaN then so do double and long double, because of
>> 6.2.5 paragraph 10. Similarly for infinity (or infinities).
>
> Agreed. 6.2.5p10 says:
>
> There are three real floating types, designated as float, double,
> and long double. The set of values of the type float is a subset of
> the set of values of the type double; the set of values of the type
> double is a subset of the set of values of the type long double.
>
> (No need to make everyone look it up.)

I just noticed that leaves open the possibility, for example, that
double supports infinity but float doesn't.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: contradiction about the INFINITY macro

<20211009194742$9114@zira.vinc17.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=366&group=comp.std.c#366

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!i2pn.org!aioe.org!4JUmjLgy+Wx+kwpjMvj36w.user.46.165.242.75.POSTED!not-for-mail
From: vincent-...@vinc17.net (Vincent Lefevre)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Sat, 9 Oct 2021 19:49:27 -0000 (UTC)
Organization: a training zoo
Message-ID: <20211009194742$9114@zira.vinc17.org>
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> <877dewimc9.fsf@nosuchdomain.example.com> <20211004092110$b3e8@zira.vinc17.org> <87r1d0g0dh.fsf@nosuchdomain.example.com> <861r4xq6a8.fsf@linuxsc.com> <87czog7uso.fsf@nosuchdomain.example.com> <874k9r7419.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="5078"; posting-host="4JUmjLgy+Wx+kwpjMvj36w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.6.0-20210823 ("Coleburn") (Linux/5.14.0-2-amd64 (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: Vincent Lefevre - Sat, 9 Oct 2021 19:49 UTC

In article <874k9r7419.fsf@nosuchdomain.example.com>,
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> > Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> >> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> >>> Vincent Lefevre <vincent-news@vinc17.net> writes:
> >>>> In article <877dewimc9.fsf@nosuchdomain.example.com>,
> >>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> >>>>> Vincent Lefevre <vincent-news@vinc17.net> writes:
> >>>>>
> >>>>>> In article <87lf3ehy4v.fsf@nosuchdomain.example.com>,
> >>>>>> Even if FP_INFINITE could be defined conditionally, this would
> >>>>>> not imply that INFINITY is usable, since for instance, long
> >>>>>> double may have an infinity but not float.
> >>>>>
> >>>>> The standard only defines INFINITY and NAN for type float. I
> >>>>> think the implication is that it assumes either all floating types
> >>>>> have NaNs and/or infinities, or none do. That might be a valid
> >>>>> assumption.
> >>>>
> >>>> But the standard doesn't say that explicitly. It even just says
> >>>> "if and only if the implementation supports quiet NaNs for the
> >>>> float type". If the intent were to have NaN support for all the
> >>>> FP types or none, why doesn't it say "... for the floating types"
> >>>> instead of "... for the float type"?
> >>>
> >>> Since the NAN macro is of type float (if it's define), it only makes
> >>> sense to define it that way. Presumably if an implementation had
> >>> NaN for float but not for double, it would define NAN.
> >>
> >> If float has a NaN then so do double and long double, because of
> >> 6.2.5 paragraph 10. Similarly for infinity (or infinities).
> >
> > Agreed. 6.2.5p10 says:
> >
> > There are three real floating types, designated as float, double,
> > and long double. The set of values of the type float is a subset of
> > the set of values of the type double; the set of values of the type
> > double is a subset of the set of values of the type long double.
> >
> > (No need to make everyone look it up.)

> I just noticed that leaves open the possibility, for example, that
> double supports infinity but float doesn't.

This is what I had said above:

"[...] for instance, long double may have an infinity but not float."

--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Re: contradiction about the INFINITY macro

<20211009195154$ec8a@zira.vinc17.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=367&group=comp.std.c#367

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!i2pn.org!aioe.org!4JUmjLgy+Wx+kwpjMvj36w.user.46.165.242.75.POSTED!not-for-mail
From: vincent-...@vinc17.net (Vincent Lefevre)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Sat, 9 Oct 2021 20:05:38 -0000 (UTC)
Organization: a training zoo
Message-ID: <20211009195154$ec8a@zira.vinc17.org>
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>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="20538"; posting-host="4JUmjLgy+Wx+kwpjMvj36w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.6.0-20210823 ("Coleburn") (Linux/5.14.0-2-amd64 (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: Vincent Lefevre - Sat, 9 Oct 2021 20:05 UTC

In article <86sfxbpm9d.fsf@linuxsc.com>,
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

> 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.

diagnostic and undefined behavior. So this is not better than
the case where INFINITY would be conditionally defined. At least,
with a conditionally defined macro, one can test it and have a
fallback, e.g. a more complex algorithm.

> 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.

This will not work if the main code requires infinity with a possible
fallback. As a workaround, one could test HUGE_VAL as you said, but
there are still potential issues. For instance, the standard does not
guarantee that HUGE_VAL has the largest possible double value, and
this can break algorithms based on comparisons / sorting.

See note 232:

"HUGE_VAL, HUGE_VALF, and HUGE_VALL can be positive infinities in
an implementation that supports infinities."

with just "can be" instead of "shall be".

--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Re: contradiction about the INFINITY macro

<20211009201151$a68b@zira.vinc17.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=368&group=comp.std.c#368

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!i2pn.org!aioe.org!4JUmjLgy+Wx+kwpjMvj36w.user.46.165.242.75.POSTED!not-for-mail
From: vincent-...@vinc17.net (Vincent Lefevre)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Sat, 9 Oct 2021 20:17:09 -0000 (UTC)
Organization: a training zoo
Message-ID: <20211009201151$a68b@zira.vinc17.org>
References: <20210930012112$48d9@zira.vinc17.org> <87pmsqizrh.fsf@nosuchdomain.example.com> <20210930105413$d6e8@zira.vinc17.org> <86wnmoov7c.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="29232"; posting-host="4JUmjLgy+Wx+kwpjMvj36w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.6.0-20210823 ("Coleburn") (Linux/5.14.0-2-amd64 (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: Vincent Lefevre - Sat, 9 Oct 2021 20:17 UTC

In article <86wnmoov7c.fsf@linuxsc.com>,
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

> What occurs is defined behavior and (for implementations that do
> not have the needed value for infinity) violates a constraint.
> A diagnostic must be produced.

If this is defined behavior, where is the result of an overflow
defined by the standard? (I can see only 7.12.1p5, but this is
for math functions; here, this is a constant that overflows.)

--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Re: contradiction about the INFINITY macro

<87o87x6g7o.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=369&group=comp.std.c#369

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Sat, 09 Oct 2021 14:28:11 -0700
Organization: None to speak of
Lines: 63
Message-ID: <87o87x6g7o.fsf@nosuchdomain.example.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>
<877dewimc9.fsf@nosuchdomain.example.com>
<20211004092110$b3e8@zira.vinc17.org>
<87r1d0g0dh.fsf@nosuchdomain.example.com> <861r4xq6a8.fsf@linuxsc.com>
<87czog7uso.fsf@nosuchdomain.example.com>
<874k9r7419.fsf@nosuchdomain.example.com>
<20211009194742$9114@zira.vinc17.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="7e8bdc203eb18db33af681d8600aa123";
logging-data="12786"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mxc3S/C+W3W5+NHaTYCYx"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:p4VRN6qxevLhRPnD4mktyFA2ePg=
sha1:/UKxxq7V93W+Vo3iZieo14663po=
 by: Keith Thompson - Sat, 9 Oct 2021 21:28 UTC

Vincent Lefevre <vincent-news@vinc17.net> writes:
> In article <874k9r7419.fsf@nosuchdomain.example.com>,
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> > Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>> >> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> >>> Vincent Lefevre <vincent-news@vinc17.net> writes:
>> >>>> In article <877dewimc9.fsf@nosuchdomain.example.com>,
>> >>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> >>>>> Vincent Lefevre <vincent-news@vinc17.net> writes:
>> >>>>>
>> >>>>>> In article <87lf3ehy4v.fsf@nosuchdomain.example.com>,
>> >>>>>> Even if FP_INFINITE could be defined conditionally, this would
>> >>>>>> not imply that INFINITY is usable, since for instance, long
>> >>>>>> double may have an infinity but not float.
>> >>>>>
>> >>>>> The standard only defines INFINITY and NAN for type float. I
>> >>>>> think the implication is that it assumes either all floating types
>> >>>>> have NaNs and/or infinities, or none do. That might be a valid
>> >>>>> assumption.
>> >>>>
>> >>>> But the standard doesn't say that explicitly. It even just says
>> >>>> "if and only if the implementation supports quiet NaNs for the
>> >>>> float type". If the intent were to have NaN support for all the
>> >>>> FP types or none, why doesn't it say "... for the floating types"
>> >>>> instead of "... for the float type"?
>> >>>
>> >>> Since the NAN macro is of type float (if it's define), it only makes
>> >>> sense to define it that way. Presumably if an implementation had
>> >>> NaN for float but not for double, it would define NAN.
>> >>
>> >> If float has a NaN then so do double and long double, because of
>> >> 6.2.5 paragraph 10. Similarly for infinity (or infinities).
>> >
>> > Agreed. 6.2.5p10 says:
>> >
>> > There are three real floating types, designated as float, double,
>> > and long double. The set of values of the type float is a subset of
>> > the set of values of the type double; the set of values of the type
>> > double is a subset of the set of values of the type long double.
>> >
>> > (No need to make everyone look it up.)
>
>> I just noticed that leaves open the possibility, for example, that
>> double supports infinity but float doesn't.
>
> This is what I had said above:
>
> "[...] for instance, long double may have an infinity but not float."

Yes. My initial assumption was that the three floating-point types
could independently have or not have infinities. Tim cited 6.2.5p10,
which implies that if float has infinities, then the wider types do
also. (I wonder if the authors had infinities and NaNs in mind when
they wrote that, but the implication is still there.)

If long double has infinities, then float and double may or may not.
If float has infinities, then double and long double must.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: contradiction about the INFINITY macro

<sk1pd2$5e3$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=371&group=comp.std.c#371

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Mon, 11 Oct 2021 12:40:02 -0400
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <sk1pd2$5e3$3@dont-email.me>
References: <20210930012112$48d9@zira.vinc17.org>
<87pmsqizrh.fsf@nosuchdomain.example.com>
<20210930105413$d6e8@zira.vinc17.org> <86wnmoov7c.fsf@linuxsc.com>
<20211009201151$a68b@zira.vinc17.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 11 Oct 2021 16:40:02 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a7992d9703e22c1e39fde38bf0a2b887";
logging-data="5571"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SIy2BGDDT5tmFRzkw04ZeHVzgZS5sUG0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:f9AM+sBzhyPQ/y5fwm6OC7+PMOA=
In-Reply-To: <20211009201151$a68b@zira.vinc17.org>
Content-Language: en-US
 by: James Kuyper - Mon, 11 Oct 2021 16:40 UTC

On 10/9/21 4:17 PM, Vincent Lefevre wrote:
> In article <86wnmoov7c.fsf@linuxsc.com>,
> Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>
>> What occurs is defined behavior and (for implementations that do
>> not have the needed value for infinity) violates a constraint.
>> A diagnostic must be produced.
>
> If this is defined behavior, where is the result of an overflow
> defined by the standard? (I can see only 7.12.1p5, but this is
> for math functions; here, this is a constant that overflows.)

"For decimal floating constants, and also for hexadecimal floating
constants when FLT_RADIX is not a power of 2, the result is either
the nearest representable value, or the larger or smaller representable
value immediately adjacent to the nearest representable value, chosen in
an implementation-defined manner.
For hexadecimal floating constants when FLT_RADIX is a power of 2, the
result is correctly rounded." (6.4.4.2p3)

In the case of overflow, for a type that cannot represent infinity,
there is only one "nearest representable value", which is DBL_MAX.

Re: contradiction about the INFINITY macro

<sk1pdj$5e3$4@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=372&group=comp.std.c#372

  copy link   Newsgroups: comp.std.c
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.std.c
Subject: Re: contradiction about the INFINITY macro
Date: Mon, 11 Oct 2021 12:40:18 -0400
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <sk1pdj$5e3$4@dont-email.me>
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>
<20211009195154$ec8a@zira.vinc17.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 11 Oct 2021 16:40:19 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a7992d9703e22c1e39fde38bf0a2b887";
logging-data="5571"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18mvSV2aPNVbAMK5+6PP6ljRT+syxYnr7g="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:LV3VIZpFB9TVbhnfFIUsWcNchl0=
In-Reply-To: <20211009195154$ec8a@zira.vinc17.org>
Content-Language: en-US
 by: James Kuyper - Mon, 11 Oct 2021 16:40 UTC

On 10/9/21 4:05 PM, Vincent Lefevre wrote:
....
> there are still potential issues. For instance, the standard does not
> guarantee that HUGE_VAL has the largest possible double value, and

In fact, a fully conforming implementation could define it to match
DBL_MIN. I think that's a defect.

Pages:1234
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor