Public Comment Number PC-UK0286 ISO/IEC CD2 9899 (SC22N2794) Public Comment =========================================== Date: 1998-12-13 Author: C.D.W.Feather Author Affiliation: Self Postal Address: Demon Internet Ltd. 322 Regents Park Road London N3 2QQ United Kingdom E-mail Address: Telephone Number: +44 181 371 1138 Fax Number: +44 181 371 1037 Category: Inconsistency Committee Draft subsection: 7.6, 7.6.3 Title: Inconsistencies in fesetround Detailed description: It is not clear from the text whether an implementation is required to allow the floating-point rounding direction to be changed at runtime. The wording of 7.6p7 implies that those modes defined must be settable at runtime ("... supports getting and setting ..."), but if this is the case then 7.6.3.2p4 (example 1) would have no need to call assert on the results of the fesetround call, since that call could not fail (if FE_UPWARD is not defined the code is in error). On the other hand, 7.6.3.2p2 implies that setting succeeds whenever the argument is one of the defined FE_ macros, and in any case 7.6.3.2p3 is ambiguous. Even if the mode cannot be set at runtime, it may be the case that the code is compiled under more than one mode, and it is therefore convenient to be able to retrieve the current mode. Option A -------- If the intention is that there may be rounding modes that can be in effect but cannot be set by the program, then make the following changes: Change 7.6p7 to: Each of the macros FE_DOWNWARD FE_TONEAREST FE_TOWARDZERO FE_UPWARD is defined if the implementation supports this rounding direction and it might be returned by the fegetround function; it might be possible to set this direction with the fesetround function. Additional rounding directions ... [unchanged] Change 7.6.3.2p2 to: The fesetround function attempts to establish the rounding direction represented by its argument round. If the new rounding direction cannot be established, it is left unchanged. Change 7.6.3.2p3 to: The fesetround function returns a zero value if and only if the new rounding direction has been established. Example 1 is valid in this option, though it may be desirable to replace the assert by some other action. Option B -------- If the intention is that an implementation must allow the mode to be set successfully to any FE_* macro that is defined, then make the following changes: Change 7.6.3.2p3 to: The fesetround function returns a zero value if and only if the argument is equal to a rounding direction macro defined in the header (that is, if and only if the requested rounding direction is one supported by the implementation). In 7.6.3.2p4, change the lines: setround_ok = fesetround (FE_UPWARD); assert(setround_ok); to: assert(defined (FE_UPWARD)); fesetround(FE_UPWARD); // Can't fail and delete the declaration of setround_ok.