[Cfp-interest 2207] Re: contradiction about the INFINITY macro

Vincent Lefevre vincent at vinc17.net
Wed Oct 6 00:01:48 PDT 2021


On 2021-10-05 18:41:12 -0700, Fred J. Tydeman wrote:
> He also mentioned the C99 rationale:
> 
> 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.

But he also says that the standard itself doesn't say whether
FP_INFINITE is defined conditionally.

As I read the standard, FP_INFINITE is always defined, and changing
it to conditionally defined could break existing programs: those that
test whether a value is of kind FP_INFINITE, which is normally safe
even in the case where infinity is not supported. For instance, with
code like

  printf ("Value if infinite: %s\n", c == FP_INFINITE ? "yes" : "no");

-- 
Vincent Lefèvre <vincent at 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)


More information about the Cfp-interest mailing list