This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: maxval on -inf and nan in Fortran
- From: Jiufu Guo <guojiufu at linux dot ibm dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: Tobias Burnus <tobias at codesourcery dot com>, Segher Boessenkool <segher at kernel dot crashing dot org>, Steve Kargl <sgk at troutmask dot apl dot washington dot edu>, <fortran at gcc dot gnu dot org>, <gcc-patches at gcc dot gnu dot org>, <wschmidt at linux dot ibm dot com>, <jakub at gcc dot gnu dot org>
- Date: Mon, 02 Mar 2020 12:07:00 +0800
- Subject: Re: maxval on -inf and nan in Fortran
- References: <1582866148-111608-1-git-send-email-guojiufu@linux.ibm.com> <20200228052527.GA51188@troutmask.apl.washington.edu> <20200228145311.GA22482@gate.crashing.org> <604d0e84-21af-7f34-0a60-a9e7503d3eff@codesourcery.com> <alpine.DEB.2.21.2002282157340.23276@digraph.polyomino.org.uk>
Joseph Myers <joseph@codesourcery.com> writes:
> On Fri, 28 Feb 2020, Tobias Burnus wrote:
>
>> Regarding MIN and MAX: I think the IEEE 754 decided at some point
>> decided that MAX(x, NaN) = x (IEEE 754:2008 alias ISO 60559:2011, if I
>> recall correctly). I think one has to check what exactly the test case
>> does and what is guaranteed where. I also do not know whether a more
>> recent IEEE 754 (754:2019) has changed something again.
>
> It has. The maxNum/minNum operations from IEEE 754-2008 were removed and
> replaced by recommended operations maximum/minimum (treat NaNs the same
> way as other operations do, i.e. produce a quiet NaN result if either
> operand is a NaN) and maximumNumber/minimumNumber (return the number if
> the other operand is a NaN, even a signaling NaN, with "invalid" raised in
> the signaling NaN case). Those new operations also treat +0 as greater
> than -0, whereas maxNum/minNum did not specify the result in that case.
> (The choice of which operand is the result is still unspecified when the
> two operands are different DFP members of the same cohort, i.e. with
> different quantum exponents.)
Hi,
Thanks for all your great comments!
IEEE 754 also updates the behavior of min/max on NaN, and
seems try to meet difference purpose with special operations.
So, I feel GNU Fortran manual is still a good decision as:
https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gfortran/MAX-and-MIN-intrinsics-with-REAL-NaN-arguments.html#MAX-and-MIN-intrinsics-with-REAL-NaN-arguments
It is undefined to use max/min on NaN without check IS_NAN or without
using specified IEEE operations.
Jiufu