On Tue, Jul 17, 2018 at 11:06 PM, Janne Blomqvist <blomqvist.ja...@gmail.com > wrote:
> On Tue, Jul 17, 2018 at 6:36 PM, Thomas Koenig <tkoe...@netcologne.de> > wrote: > >> Hi Kyrill, >> >> The current implementation expands to: >>> mvar = a1; >>> if (a2 .op. mvar || isnan (mvar)) >>> mvar = a2; >>> if (a3 .op. mvar || isnan (mvar)) >>> mvar = a3; >>> ... >>> return mvar; >>> >>> That is, if one of the operands is a NaN it will return the other >>> argument. >>> If both (all) are NaNs, it will return NaN. This is the same as the >>> semantics of fmin/max >>> as far as I can tell. >>> >> >> I've looked at the F2008 standard, and, interestingly enough, the >> requirement on MIN and MAX do not mention NaNs at all. 13.7.106 >> has, for MAX, >> >> Result Value. The value of the result is that of the largest argument. >> >> plus some stuff about character variables (not relevant here). Similar >> for MIN. >> > > FWIW, this has not changed in the latest(?) draft for F2018 (N2146), see > 16.9.125. > > Also, the section on IEEE_ARITHMETIC (14.9) does not mention >> comparisons; also, "Complete conformance with IEC 60559:1989 is not >> required", what is required is the correct support for +,-, and *, >> plus support for / if IEEE_SUPPORT_DIVIDE is covered. >> > > Interestingly, here the F2018 draft has new intrinsics in the > IEEE_ARITHMETIC module, IEEE_MAX_NUM, IEEE_MAX_NUM_MAG, IEEE_MIN_NUM, > IEEE_MIN_NUM_MAG. These correspond to the {max,min}num{,_mag} operations in > IEEE 754-2008, which AFAICT has the same NaN semantics as __builtin_fmax > etc. > > >> So, the Fortran standard does not impose many requirements. > > > If so, why don't we just use {MAX,MIN}_EXPR unconditionally? Those who > worry about the behavior wrt. NaNs, infinities etc. can use the intrinsics > from IEEE_ARITHMETIC? > > > This thread also has some interesting discussion on the topic: > https://github.com/JuliaLang/julia/issues/7866 > Oh, and on http://754r.ucbtest.org/ there is information about the next update after IEEE 754-2008. In particular, http://754r.ucbtest.org/changes.html notes that the above mentioned {max,min}num{,_mag} have been deleted, and "new {min,max}imum{,Number,Magnitude,MagnitudeNumber} operations are recommended; NaN and signed zero handling are changed from 754-2008 5.3.1. ". -- Janne Blomqvist