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

New test cases to verify that SQLite handles bound NaN, +Inf, and -Inf

floating point values correctly.  Improvements to the text->real conversion
routine so that it generates +Inf and -Inf at appropriate times.
Tickets #3101 and #3060. (CVS 5116)

FossilOrigin-Name: 3ff2f1cdc9c57bca56de6cdc0ad5edc95b0606a0
This commit is contained in:
drh
2008-05-11 11:07:06 +00:00
parent d2dadc9647
commit a06f17fe2e
6 changed files with 211 additions and 40 deletions

View File

@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.227 2008/05/09 13:47:59 drh Exp $
** $Id: util.c,v 1.228 2008/05/11 11:07:07 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@@ -262,6 +262,7 @@ int sqlite3AtoF(const char *z, double *pResult){
int sign = 1;
const char *zBegin = z;
LONGDOUBLE_TYPE v1 = 0.0;
int nSignificant = 0;
while( isspace(*(u8*)z) ) z++;
if( *z=='-' ){
sign = -1;
@@ -269,16 +270,29 @@ int sqlite3AtoF(const char *z, double *pResult){
}else if( *z=='+' ){
z++;
}
while( z[0]=='0' ){
z++;
}
while( isdigit(*(u8*)z) ){
v1 = v1*10.0 + (*z - '0');
z++;
nSignificant++;
}
if( *z=='.' ){
LONGDOUBLE_TYPE divisor = 1.0;
z++;
if( nSignificant==0 ){
while( z[0]=='0' ){
divisor *= 10.0;
z++;
}
}
while( isdigit(*(u8*)z) ){
v1 = v1*10.0 + (*z - '0');
divisor *= 10.0;
if( nSignificant<18 ){
v1 = v1*10.0 + (*z - '0');
divisor *= 10.0;
nSignificant++;
}
z++;
}
v1 /= divisor;