[Cfp-interest 1315] Re: agenda item "Rounding of negated floating constants under FENV_ROUND pragma"

Mike Cowlishaw mfc at speleotrove.com
Tue May 14 23:38:21 PDT 2019


 

Here's an issue I noticed when reviewing the C2X drafts:

Previously, floating constants were always evaluated at translation time,
using default rounding. Now, with TS 18661-1 and 2, constant rounding modes
set by the FENV_ROUND and FENV_DEC_ROUND pragmas affect floating constants
within the scope of the pragma. A C floating constant does not include a
sign, which C regards as a unary operator. Thus, rounding of a negated
constant (e.g., -0.1) is done before negation, which for rounding up or down
is undesirable, and is unlike the treatment of the corresponding string
("-0.1") by the strtod family as required by F.5. 


I  suppose one could argue that this gives the programmer the choice.   (Or
they could use decimal arithmetic, of course :-).)

Mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20190515/6c2c3f53/attachment.html 


More information about the Cfp-interest mailing list