[Cfp-interest 2323] Re: infinity and exceptions

Fred J. Tydeman tydeman at tybor.com
Thu Jan 13 21:06:35 PST 2022


On Fri, 14 Jan 2022 14:22:00 +1100 (AEDT) Damian McGuckin wrote:
>
>On Thu, 13 Jan 2022, Fred J. Tydeman wrote:
>
>>>Infinity does not propagate. A result may be an infinity, but
>>>not always, e.g. 1 / +inf = +0, and the sign may be different:
>>>0 - +inf = -inf.
>>>
>>>>I do not see any place in the C standard that the use of
>>>>INFINITY shall be quiet (in most cases).  One exception is
>>>>INFINITY / INFINITY (which raises invalid)..
>>>
>>>and 0 * INFINITY.
>>>
>>
>>OK.  Wrong way to solve the problem I see.
>
>I am unsure of what you mean there.
>
>>How about adding to 5.2.4.2.2 #16 and #17:
>>16: The evaluation of INFINITY does not raise any FP exceptions.
>>17: The evaluation of NAN does not raise any FP exceptions.
>
>Yes. But then again, how do you evaluate NAN? You can assign it.

I have been sent the output of a program that did
  float f;
  f = NAN;
and the raised overflow, inexact, and invalid.
My guess:  It appears that NAN was defined as (INFINITY * 0.f)
and INFINITY was defined as (LDBL_MAX * LDBL_MAX)


---
Fred J. Tydeman        Tydeman Consulting
tydeman at tybor.com      Testing, numerics, programming
+1 (702) 608-6093      Vice-chair of PL22.11 (ANSI "C")
Sample C99+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.



More information about the Cfp-interest mailing list