Change the implementation of the NaN recognition to be more cross-platform.
Ticket #3089. (CVS 5060)

FossilOrigin-Name: 07fd9a8c6ca0876f7ec447ce65173957005dc75c
diff --git a/src/printf.c b/src/printf.c
index 4e75257..eb90de4 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -474,7 +474,7 @@
         if( xtype==etFLOAT ) realvalue += rounder;
         /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
         exp = 0;
-        if( sqlite3_isnan(realvalue) ){
+        if( sqlite3IsNaN(realvalue) ){
           bufpt = "NaN";
           length = 3;
           break;
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index d52a04c..fd7d760 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.697 2008/04/28 12:54:15 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.698 2008/04/28 16:55:26 drh Exp $
 */
 #ifndef _SQLITEINT_H_
 #define _SQLITEINT_H_
@@ -191,8 +191,6 @@
 #include <assert.h>
 #include <stddef.h>
 
-#define sqlite3_isnan(X)  ((X)!=(X))
-
 /*
 ** If compiling for a processor that lacks floating point support,
 ** substitute integer for floating-point
@@ -1766,6 +1764,8 @@
 void *sqlite3DbRealloc(sqlite3 *, void *, int);
 int sqlite3MallocSize(void *);
 
+int sqlite3IsNaN(double);
+
 char *sqlite3MPrintf(sqlite3*,const char*, ...);
 char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
 #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
diff --git a/src/util.c b/src/util.c
index 28cfffa..2a7d7a2 100644
--- a/src/util.c
+++ b/src/util.c
@@ -14,7 +14,7 @@
 ** This file contains functions for allocating memory, comparing
 ** strings, and stuff like that.
 **
-** $Id: util.c,v 1.222 2008/04/16 00:49:12 drh Exp $
+** $Id: util.c,v 1.223 2008/04/28 16:55:26 drh Exp $
 */
 #include "sqliteInt.h"
 #include <stdarg.h>
@@ -22,6 +22,14 @@
 
 
 /*
+** Return true if the floating point value is Not a Number.
+*/
+int sqlite3IsNaN(double x){
+  volatile double y = x;
+  return x!=y;
+}
+
+/*
 ** Set the most recent error code and error string for the sqlite
 ** handle "db". The error code is set to "err_code".
 **
diff --git a/src/vdbe.c b/src/vdbe.c
index 78183fc..2f027e9 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -43,7 +43,7 @@
 ** in this file for details.  If in doubt, do not deviate from existing
 ** commenting and indentation practices when changing or adding code.
 **
-** $Id: vdbe.c,v 1.735 2008/04/25 12:25:42 drh Exp $
+** $Id: vdbe.c,v 1.736 2008/04/28 16:55:26 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1195,7 +1195,7 @@
         break;
       }
     }
-    if( sqlite3_isnan(b) ){
+    if( sqlite3IsNaN(b) ){
       goto arithmetic_result_is_null;
     }
     pOut->r = b;
diff --git a/src/vdbemem.c b/src/vdbemem.c
index f45f384..9f831ec 100644
--- a/src/vdbemem.c
+++ b/src/vdbemem.c
@@ -482,7 +482,7 @@
 ** manifest type REAL.
 */
 void sqlite3VdbeMemSetDouble(Mem *pMem, double val){
-  if( sqlite3_isnan(val) ){
+  if( sqlite3IsNaN(val) ){
     sqlite3VdbeMemSetNull(pMem);
   }else{
     sqlite3VdbeMemRelease(pMem);