(j3.2006) FRACTION: zeros, infinities and NaNs
Tue Sep 23 20:31:48 EDT 2008
Bill Long wrote:
> The changes for FRACTION for f08 are in paper 07-200r1, which includes
> extensive explanation. These changes were a small part of Interp
> F03/0042 that was filed against f03.
I considered the possibility that there was an interp that
changed the semantics of FRACTION. I didn't find one. The
text of F03/000042 still proposes that FRACTION(Inf) = Inf.
The paper 07-200r1 makes it clear that the change is an
incompatible change from Fortran 2003. The committee's
response to one of my comments on CD 1539-1 said that all
incompatible changes are listed in Section 1.5. This one
is not listed there.
The proposed text in 07-200r1 is clearer than the text in
CD 1539-1. The proposed text retains the statement
If X is an IEEE NaN, the result is the same NaN.
The text in CD 1539-1 is
If X has the value zero or is an IEEE NaN, the
result has the same value as X.
That statement is dubious, given that IEEE NaNs do not
The proposed text in 07-200r1 states that applying FRACTION
to an infinity shall raise an invalid exception. That
statement did not make it into CD 1593-1. Should it have?
The Fortran 2003 standard, the paper 07-200r1, and CD 1539-1
only loosely specify what the result of applying FRACTION to
a zero value should be. I suspect that the intent is that on
a processor that distinguishes between plus and minus zero
FRACTION of a plus zero should be a plus zero and FRACTION
of a minus zero should be a minus zero. On many machines
there are several different representations of zero values.
I believe that the intent of the standard is that FRACTION
of a zero value should return the same representation of that
> I suspect that we omitted the
> "incompatible change" text in hopes of attacking the interp before f08
> was published. At this late date, it might be worth revisiting.
> Robert Corbett wrote:
>> The specification of the intrinsic function FRACTION in
>> Section 13.7.40 of the Fortran 2003 standard states
>> If X has the value zero, the result has the
>> value zero. If X is and IEEE infinity, the
>> result is that infinity. If X is an IEEE NaN,
>> the result is that NaN.
>> The related language in Section 13.7.63 of CD 1539-1
>> If X has the value zero or is an IEEE NaN,
>> the result has the same value as X. If X
>> is an IEEE infinity, the result is an
>> IEEE NaN.
>> The change in the treatment of IEEE infinities is an
>> incompatible change. If it were an intentional change,
>> it would, of course, be listed as an incompatible
>> change in Section 1.5.2 of CD 1539-1. Since it is not
>> listed in Section 1.5.2, I assume it is an unintended
>> The change to the specification of the treatment of
>> IEEE NaNs is troubling. It is unclear what it means
>> for NaNs to have the same value, given that NaNs have
>> no value.
>> Is the new wording regarding zeros intended to mean
>> that on a processor that distinguishes between zeros
>> with positive and negative signs, the sign must be
>> preserved? If so, it should say so. A zero value
>> with a positive sign and a zero value with a negative
>> sign both have the same value (zero).
>> The Fortran 2003 standard seems to say that if the
>> actual argument of a call of FRACTION is a signaling
>> NaN, that signaling NaN must be returned. That could
>> be difficult to implement on some hardware. Is that
>> really the intent? Is FRACTION allowed to signal an
>> invalid exception if its actual argument is a
>> signaling NaN?
>> Bob Corbett
>> J3 mailing list
>> J3 at j3-fortran.org
More information about the J3