[Cfp-interest 2672] Re: floating constants issue

Jim Thomas jaswthomas at sbcglobal.net
Tue Jan 31 17:28:04 PST 2023


> On Jan 31, 2023, at 7:59 AM, Vincent Lefevre <vincent at vinc17.net> wrote:
> 
> On 2023-01-31 07:30:34 -0800, Jim Thomas wrote:
>> Maybe
>> 
>> All floating constants of the same source form shall convert to the
>> same internal format and, provided they are subject to the same
>> translation-time rounding direction (either the default or a
>> constant rounding mode other that FE_DYNAMIC set by an FENV_ROUND
>> or FENV_DEC_ROUND pragma), to the same value.
>> 
>> But that would suggest that same-form floating constants could have
>> different values under FE_DYNAMIC. Setting to FE_DYNAMIC should not
>> affect the translation time conversion of floating constants in that
>> they would still get default translation-time rounding.
> 
> This is not what 7.6.2p4 says. At the end of this paragraph:
> "Floating constants (6.4.4.2) of a standard floating type
> that occur in the scope of a constant rounding mode shall be
> interpreted according to that mode."
> 
> So, the dynamic rounding mode will be used in this case.
> 
> Or perhaps 7.6.2p4 should be changed.

As noted at the CFP meeting today …

An FENV_ROUND pragma with direction FE_DYNAMIC doesn’t establish a constant rounding mode, though in a few places the spec implies or suggests it does. For example, 7.6.2 #3 has “ … or the specified constant rounding mode is FE_DYNAMIC”.

For FENV_DEC_ROUND, 7.6.3 #2 says "dec-direction shall be one of the decimal rounding direction macro names (FE_DEC_DOWNWARD, FE_DEC_TONEAREST, FE_DEC_TONEARESTFROMZERO, FE_DEC_TOWARDZERO, and FE_DEC_UPWARD) defined in 7.6, to specify a constant rounding mode, or FE_DEC_DYNAMIC, to specify dynamic rounding.” There should be similar words for FENV_ROUND.

Here’s a draft for changes to clarify that FE_DYNAMIC does not establish a constant rounding mode:

https://wiki.edg.com/pub/CFP/WebHome/Floating_constants_issue-20230131.pdf

- Jim Thomas

> 
>>> BTW, is there a way to restore the static rounding mode when
>>> outside external declarations? This would be important if one
>>> wants to use this pragma in a header file.
>> 
>> It can be “restored" to FE_DYNAMIC which serves as a “default”.
> 
> See above. This is not the default for constants.
> 
> -- 
> 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)
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20230131/82bb9468/attachment.htm>


More information about the Cfp-interest mailing list