[J3] SNaN from IEEE_VALUE, was RE: Question on overflow and run-time detection of infinity?
Malcolm Cohen
malcolm at nag-j.co.jp
Tue Nov 27 03:02:20 EST 2018
We’ve had this discussion before. The old IEEE-754 allows copying a SNaN to produce a QNaN and raise INVALID. That’s why we do.
Furthermore (and closely related!) the ABI for floating-point function results on the x87 passes the return value on the fp stack. And the registers in the fp stack don’t have SNaN capability – loading an SNaN from memory produces a QNaN in the register (plus an INVALID signal).
That’s the second reason we have those weasel-words there!
If one is not using an x87 (which means 32-bit mode), then these words are highly unlikely to be relevant.
In any case, what we have (for consistency with IEEE and still-in-use hardware) is the ability to reliably set things to NaN, and on most systems that will be SNaN. I’d agree that we didn’t end up with the optimum situation here, but it’s such a small niggle that I don’t think it’s worth spending any more time on than we already have.
Of course if you have this issue on a particular system, you could always ask the compiler vendor to do some “magic” (i.e. not treat this as a normal function) to get the result you want. By the time F202x comes out it may well be that virtually no-one is still using x87 anyway (Apple in particular being very keen to get rid of 32-bit mode!).
Cheers,
--
..............Malcolm Cohen, NAG Oxford/Tokyo.
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Van Snyder via J3
Sent: Tuesday, November 27, 2018 3:35 PM
To: j3 at mailman.j3-fortran.org
Cc: Van Snyder <van.snyder at jpl.nasa.gov>
Subject: Re: [J3] Question on overflow and run-time detection of infinity?
On Tue, 2018-11-27 at 11:13 +0900, Malcolm Cohen via J3 wrote:
> You can see this by the wording which allows
> IEEE_VALUE(x,IEEE_SIGNALING_NAN) to raise INVALID and have the
> signalling NaN converted to a quiet NaN.
Since it's OK for a processor to supply a quiet NaN when a signaling NaN
is requested,
x = IEEE_VALUE(x,IEEE_SIGNALING_NAN)
might not assign a signaling NaN to X. How does one reliably fill a
real variable (scalar or otherwise) with signaling NaN?
Disclaimer
The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. Please see our Privacy Notice <https://www.nag.co.uk/content/privacy-notice> for information on how we process personal data and for details of how to stop or limit communications from us.
This e-mail has been scanned for all viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20181127/2312a1d4/attachment-0001.html>
More information about the J3
mailing list