[Cfp-interest 1411] Re: SNANF

Jim Thomas jaswthomas at sbcglobal.net
Sat Sep 21 17:19:52 PDT 2019



> On Aug 21, 2019, at 10:51 AM, Fred J. Tydeman <tydeman at tybor.com> wrote:
> 
> On Thu, 15 Aug 2019 10:40:09 -0700 (PDT) Fred J. Tydeman wrote:
>> 
>> On Wed, 14 Aug 2019 10:56:01 -0700 Jim Thomas wrote:
>>> 
>>> [+/-]SNANF isn't subject to the usual arithmetic conversions
>> 
>> Where is that stated?
>> 
>>> and isn't a floating constant,
>> 
>> Agreed, it is a constant expression.
> 
> How can you get a float constant expression without the use of a float constant?

A very good question. Yes, it’s a constant expression. C 6.6 says

> An arithmetic constant expression shall have arithmetic type and shall only have operands that are
> integer constants, floating constants, enumeration constants, character constants, sizeof expressions
> whose results are integer constants, and _Alignof expressions.


And we say the SNAN macros expand to constant expressions of the appropriate floating type. The NAN and INFINITY macros are similar. But floating constants just represent numbers, not NaNs or infinities. An expression with floating constant operands can’t evaluate to a signaling NaN. Expressions with floating constant operands can evaluate to a quiet NaN or an infinity, but not without an exception. My understanding, for IEC 60559 implementations, is that these macros are not intended to raise exceptions and need to be implemented as compiler symbols.

For the SNAN macros, instead of

	… expand to a constant expression of the respective type representing ...

we might say

	… expand to an expression of the respective type representing ... They may be used wherever a constant expression of the respective type may be used.


For the infinity and quiet NaN macros, instead of

	… expands to a constant expression of type float representing ...

we might say

	… expands to an expression of type float representing … It may be used wherever a constant expression of type float may be used.

And similarly for the decimal macros.

- Jim Thomas



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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20190921/0bae7278/attachment.html 


More information about the Cfp-interest mailing list