/ Check-in [07fd9a8c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Change the implementation of the NaN recognition to be more cross-platform. Ticket #3089. (CVS 5060)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 07fd9a8c6ca0876f7ec447ce65173957005dc75c
User & Date: drh 2008-04-28 16:55:26
Context
2008-04-28
17:12
Add tests to create and drop a virtual table during a recursive call from an application-defined function. Ticket #3080. (CVS 5061) check-in: d4d6eff3 user: drh tags: trunk
16:55
Change the implementation of the NaN recognition to be more cross-platform. Ticket #3089. (CVS 5060) check-in: 07fd9a8c user: drh tags: trunk
16:19
Fix a shared-cache mode problem triggered when sqlite3_open16() was used to open the second or subsequent connections to a utf-8 database. (CVS 5059) check-in: 20946bf6 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/printf.c.

   470    470   #else
   471    471           /* It makes more sense to use 0.5 */
   472    472           for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1){}
   473    473   #endif
   474    474           if( xtype==etFLOAT ) realvalue += rounder;
   475    475           /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
   476    476           exp = 0;
   477         -        if( sqlite3_isnan(realvalue) ){
          477  +        if( sqlite3IsNaN(realvalue) ){
   478    478             bufpt = "NaN";
   479    479             length = 3;
   480    480             break;
   481    481           }
   482    482           if( realvalue>0.0 ){
   483    483             while( realvalue>=1e32 && exp<=350 ){ realvalue *= 1e-32; exp+=32; }
   484    484             while( realvalue>=1e8 && exp<=350 ){ realvalue *= 1e-8; exp+=8; }

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.697 2008/04/28 12:54:15 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.698 2008/04/28 16:55:26 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** Include the configuration header output by 'configure' if it was run
    21     21   ** (otherwise we get an empty default).
................................................................................
   187    187   #include "parse.h"
   188    188   #include <stdio.h>
   189    189   #include <stdlib.h>
   190    190   #include <string.h>
   191    191   #include <assert.h>
   192    192   #include <stddef.h>
   193    193   
   194         -#define sqlite3_isnan(X)  ((X)!=(X))
   195         -
   196    194   /*
   197    195   ** If compiling for a processor that lacks floating point support,
   198    196   ** substitute integer for floating-point
   199    197   */
   200    198   #ifdef SQLITE_OMIT_FLOATING_POINT
   201    199   # define double sqlite_int64
   202    200   # define LONGDOUBLE_TYPE sqlite_int64
................................................................................
  1761   1759   char *sqlite3StrDup(const char*);
  1762   1760   char *sqlite3StrNDup(const char*, int);
  1763   1761   char *sqlite3DbStrDup(sqlite3*,const char*);
  1764   1762   char *sqlite3DbStrNDup(sqlite3*,const char*, int);
  1765   1763   void *sqlite3DbReallocOrFree(sqlite3 *, void *, int);
  1766   1764   void *sqlite3DbRealloc(sqlite3 *, void *, int);
  1767   1765   int sqlite3MallocSize(void *);
         1766  +
         1767  +int sqlite3IsNaN(double);
  1768   1768   
  1769   1769   char *sqlite3MPrintf(sqlite3*,const char*, ...);
  1770   1770   char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
  1771   1771   #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
  1772   1772     void sqlite3DebugPrintf(const char*, ...);
  1773   1773   #endif
  1774   1774   #if defined(SQLITE_TEST)

Changes to src/util.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Utility functions used throughout sqlite.
    13     13   **
    14     14   ** This file contains functions for allocating memory, comparing
    15     15   ** strings, and stuff like that.
    16     16   **
    17         -** $Id: util.c,v 1.222 2008/04/16 00:49:12 drh Exp $
           17  +** $Id: util.c,v 1.223 2008/04/28 16:55:26 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include <stdarg.h>
    21     21   #include <ctype.h>
    22     22   
           23  +
           24  +/*
           25  +** Return true if the floating point value is Not a Number.
           26  +*/
           27  +int sqlite3IsNaN(double x){
           28  +  volatile double y = x;
           29  +  return x!=y;
           30  +}
    23     31   
    24     32   /*
    25     33   ** Set the most recent error code and error string for the sqlite
    26     34   ** handle "db". The error code is set to "err_code".
    27     35   **
    28     36   ** If it is not NULL, string zFormat specifies the format of the
    29     37   ** error string in the style of the printf functions: The following

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.735 2008/04/25 12:25:42 drh Exp $
           46  +** $Id: vdbe.c,v 1.736 2008/04/28 16:55:26 drh Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include <ctype.h>
    50     50   #include "vdbeInt.h"
    51     51   
    52     52   /*
    53     53   ** The following global variable is incremented every time a cursor
................................................................................
  1191   1191           i64 ib = (i64)b;
  1192   1192           if( ia==0 ) goto arithmetic_result_is_null;
  1193   1193           if( ia==-1 ) ia = 1;
  1194   1194           b = ib % ia;
  1195   1195           break;
  1196   1196         }
  1197   1197       }
  1198         -    if( sqlite3_isnan(b) ){
         1198  +    if( sqlite3IsNaN(b) ){
  1199   1199         goto arithmetic_result_is_null;
  1200   1200       }
  1201   1201       pOut->r = b;
  1202   1202       MemSetTypeFlag(pOut, MEM_Real);
  1203   1203       if( (flags & MEM_Real)==0 ){
  1204   1204         sqlite3VdbeIntegerAffinity(pOut);
  1205   1205       }

Changes to src/vdbemem.c.

   478    478   }
   479    479   
   480    480   /*
   481    481   ** Delete any previous value and set the value stored in *pMem to val,
   482    482   ** manifest type REAL.
   483    483   */
   484    484   void sqlite3VdbeMemSetDouble(Mem *pMem, double val){
   485         -  if( sqlite3_isnan(val) ){
          485  +  if( sqlite3IsNaN(val) ){
   486    486       sqlite3VdbeMemSetNull(pMem);
   487    487     }else{
   488    488       sqlite3VdbeMemRelease(pMem);
   489    489       pMem->r = val;
   490    490       pMem->flags = MEM_Real;
   491    491       pMem->type = SQLITE_FLOAT;
   492    492     }