[Cfp-interest 2668] Re: floating constants issue

Vincent Lefevre vincent at vinc17.net
Tue Jan 31 07:59:46 PST 2023


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.

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


More information about the Cfp-interest mailing list