08-287r2 To: J3 From: Steve Lionel Subject: changes to the intrinsic function FRACTION Date: 2008 November 20 References: 05-152, 07-113, 07-200r1 Comment by Robert Corbett The specification of the intrinsic function FRACTION has been changed in CD 1539-1 in ways that make it less clear than the specification in the Fortran 2003 standard. The Fortran 2003 standard states (317:13.7.40l9) If X is an IEEE NaN, the result is that NaN. The CD 1539-1 specification states (348:13.7.63p5) If X has the value zero or is an IEEE NaN, the result has the same value as X. It is unclear what it means for a NaN to have the same value as another NaN. The description in Fortran 2003 is clearer. I suggest restoring the text to that of the Fortran 2003 standard. The specification of Fraction leaves many important questions unanswered. Is it the intent of the committee that applying FRACTION to a zero value on a processor that distinguishes the sign of zero shall produce a result that preserves the sign of that zero value? If so, that seems to conflict with 52:4.4.3p3. Is it the intent of the committee that the result of applying FRACTION to a zero value should be the same representation of a zero value? The IBM mainframe architecture and the Intel architecture with the DAZ bit set in the MXCSR provide many different representations of zero. It seems clear that the committee intends that the result of applying FRACTION to a signaling NaN should produce a result that is a signaling NaN. For some processors, it is difficult to return a signaling NaN. Discussion: Regarding signed zeroes, the intention is that FRACTION does not distinguish between positive and negative zero. However, the text in 52:4.4.3p3 does not discuss intrinsic function result values but rather how a negative zero, if any, is treated as an actual argument. Therefore there is no conflict. 05-152 discussed FRACTION (and EXPONENT and SET_EXPONENT) with regards to the behavior when the argument is an IEEE denormal value, saying "the intention was to treat the value as if it were held according to the model in 13.14 with the same radix b, but with an expanded exponent range. This is why the words 'for the value of X' were used in EXPONENT. It has to be this way for a denormal value since otherwise it does not lie within the model." 05-152 was passed at meeting 171 to become interp F03/0054. However, that interp did not change the text "If X has the value zero, the result has the value zero." 07-113 considered FRACTION with an argument of an IEEE infinity. That discussion is not relevant to this matter. 07-200r1 again considered FRACTION with an argument of IEEE infinity and made an edit to 07-007r1 as follows: [378:13.7.71p5+2] Change ", or is an IEEE infinity or NaN," to "or is an IEEE NaN,"; Append new sentence to paragraph "If X is an IEEE infinity, the result is an IEEE NaN." {Fix FRACTION.} We have not been able to find a definitive reference for where 07-007r1 was changed to the current wording with respect to an IEEE NaN argument. In the CD, there are other intrinsics, such as RRSPACING and SPACING, that use the language "If X is an IEEE NaN, the result is that NaN." J3 finds that this wording is clearer than "the same value as X" shown for FRACTION in the CD and proposes using the Fortran 2003 wording for FRACTION as well. J3's response: J3 agrees that the CD wording is unclear and provides an edit to resolve the issue. J3 feels that the issue of what a processor does when loading a signaling NaN is beyond the scope of the standard. Edit: [348:5] In 13.7.63, replace: "If X has the value zero or is an IEEE NaN, the result has the same value as X." with: "If X has the value zero, the result is zero. If X is an IEEE NaN, the result is that NaN."