Re: strtod ("nan") returns negative NaN

Brian Inglis <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On 2018-08-15 10:51, Joseph Myers wrote:
> On Wed, 15 Aug 2018, Paul Koning wrote:
> 
>>> * Different processors have different preferences for what a "default" 
>>> quiet NaN (e.g. one produced by an operation without NaN operands) should 
>>> look like.  Some clear all the lower mantissa bits, some set them.  If you 
>>> use the built-in functions then you generate NaNs following GCC's 
>>> knowledge of such processor conventions.
>>
>> But does that matter?  It should be sufficient to generate a legal NaN 
>> when one is requested.  Given that there are don't care bits in the 
>> representation of NaN, it might look different from one generated by the 
>> hardware as the output of some operation, but a NaN is a Nan so long as 
>> it matches what the spec says -- right?

Signalling NaNs are useful in development and for mathematicians who want to
ensure rigorous correctness: most of us and most apps would prefer NaNs remain
quiet, and interchanged data with NaNs not to create a fuss: non-zero mantissa
bits which do not constitute a signalling NaN on any known platform [NaN with
all zero mantissa bits is Inf]. Some old K-C-S draft-based or low cost
implementations may cheap out on how many or which bit(s) to check.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.