mirror of
https://github.com/sqlite/sqlite.git
synced 2025-12-03 08:01:19 +03:00
Change the implementation of the NaN recognition to be more cross-platform.
Ticket #3089. (CVS 5060) FossilOrigin-Name: 07fd9a8c6ca0876f7ec447ce65173957005dc75c
This commit is contained in:
@@ -474,7 +474,7 @@ static void vxprintf(
|
||||
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;
|
||||
|
||||
@@ -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 *sqlite3DbReallocOrFree(sqlite3 *, void *, int);
|
||||
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)
|
||||
|
||||
10
src/util.c
10
src/util.c
@@ -14,13 +14,21 @@
|
||||
** 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>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
/*
|
||||
** 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".
|
||||
|
||||
@@ -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 @@ case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( sqlite3_isnan(b) ){
|
||||
if( sqlite3IsNaN(b) ){
|
||||
goto arithmetic_result_is_null;
|
||||
}
|
||||
pOut->r = b;
|
||||
|
||||
@@ -482,7 +482,7 @@ void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
|
||||
** manifest type REAL.
|
||||
*/
|
||||
void sqlite3VdbeMemSetDouble(Mem *pMem, double val){
|
||||
if( sqlite3_isnan(val) ){
|
||||
if( sqlite3IsNaN(val) ){
|
||||
sqlite3VdbeMemSetNull(pMem);
|
||||
}else{
|
||||
sqlite3VdbeMemRelease(pMem);
|
||||
|
||||
Reference in New Issue
Block a user