strtod ("nan") returns negative NaN

Joseph Myers joseph@codesourcery.com
Wed Aug 15 15:40:00 GMT 2018


On Tue, 14 Aug 2018, Craig Howland wrote:

>      The f_QNAN value should be 0x7fc00000 regardless of byte ordering.  In

It would be better to use __builtin_nan ("") (and __builtin_nanf, 
__builtin_nanl for other types) rather than using an integer 
representation at all (of course that requires changes to other code to 
avoid requiring an integer representation there).

* Older MIPS processors have a reversed convention for what is a quiet NaN 
and what is a signaling NaN.  The present newlib code has __mips and 
__mips_nan2008 conditionals to handle that.  But that doesn't handle hppa, 
which has the same reversed convention, or sh, which also does (GCC 
doesn't know about sh doing this at present, resulting in a load of glibc 
test failures, but if you used __builtin_nan* then fewer places would need 
fixing for sh).

* 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.

-- 
Joseph S. Myers
joseph@codesourcery.com


More information about the Newlib mailing list