develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34150 - branches/vc9/src

From:
rblasch
Date:
December 20, 2008 10:48
Subject:
[svn:parrot] r34150 - branches/vc9/src
Message ID:
20081220184831.B3CC3CBA12@x12.develooper.com
Author: rblasch
Date: Sat Dec 20 10:48:30 2008
New Revision: 34150

Modified:
   branches/vc9/src/string.c

Log:
Handle NaN in string_to_num.


Modified: branches/vc9/src/string.c
==============================================================================
--- branches/vc9/src/string.c	(original)
+++ branches/vc9/src/string.c	Sat Dec 20 10:48:30 2008
@@ -2053,7 +2053,20 @@
     while (isspace((unsigned char)*p))
         p++;
 
-    f = atof(p);
+    /* Handle NaN strings.  Expand this test to handle all defined NaN
+     * values, if necessary. */
+    if (strcmp(p, "NaN") == 0)
+    {
+        /* There seems to be no NaN constant, and compilers detect
+         * constant '0.0/0.0'. */
+        FLOATVAL nan = 0.0;
+        nan /= 0.0;
+        f = nan;
+    }
+    else
+    {
+        f = atof(p);
+    }
 
     /* Not all atof()s return -0 from "-0" */
     if (*p == '-' && FLOAT_IS_ZERO(f))



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About