1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-09 14:21:03 +03:00

Add the SQLITE_HAVE_ISNAN compile-time option which, if present, causes

SQLite to use the math library isnan() function rather than its own homebrew
implementation of isnan(). (CVS 6517)

FossilOrigin-Name: 54d23521c37938b9d98f41f5547975c469c0c8f0
This commit is contained in:
drh
2009-04-17 11:57:22 +00:00
parent 382ffd9e65
commit cf9b1752cf
3 changed files with 23 additions and 9 deletions

View File

@@ -14,10 +14,11 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.249 2009/03/01 22:29:20 drh Exp $
** $Id: util.c,v 1.250 2009/04/17 11:57:22 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <math.h>
/*
** Routine needed to support the testcase() macro.
@@ -52,9 +53,19 @@ int sqlite3Assert(void){
/*
** Return true if the floating point value is Not a Number (NaN).
**
** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN.
** Otherwise, we have our own implementation that works on most systems.
*/
int sqlite3IsNaN(double x){
/* This NaN test sometimes fails if compiled on GCC with -ffast-math.
#if defined(SQLITE_HAVE_ISNAN)
/*
** Systems that support the isnan() library function should probably
** make use of it by compiling with -DSQLITE_HAVE_ISNAN. But we have
** found that many systems do not have a working isnan() function so
** this implementation is provided as an alternative.
**
** This NaN test sometimes fails if compiled on GCC with -ffast-math.
** On the other hand, the use of -ffast-math comes with the following
** warning:
**
@@ -77,6 +88,9 @@ int sqlite3IsNaN(double x){
volatile double y = x;
volatile double z = y;
return y!=z;
#else /* if defined(SQLITE_HAVE_ISNAN) */
return isnan(x);
#endif /* SQLITE_HAVE_ISNAN */
}
/*