1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Refactor the float-to-double rounding routines so that they compile without

warnings.

FossilOrigin-Name: f607ad27c1ede27af24dbee10ca867c8f7761ee3
This commit is contained in:
drh
2012-05-29 00:30:43 +00:00
parent c6bff38216
commit 0e3037ac36
3 changed files with 15 additions and 17 deletions

View File

@ -2739,6 +2739,12 @@ static int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){
return rc;
}
/*
** Rounding constants for float->double conversion.
*/
#define RNDTOWARDS (1.0 - 1.0/8388608.0) /* Round towards zero */
#define RNDAWAY (1.0 + 1.0/8388608.0) /* Round away from zero */
#if !defined(SQLITE_RTREE_INT_ONLY)
/*
** Convert an sqlite3_value into an RtreeValue (presumably a float)
@ -2748,11 +2754,7 @@ static RtreeValue rtreeValueDown(sqlite3_value *v){
double d = sqlite3_value_double(v);
float f = (float)d;
if( f>d ){
if( f<0.0 ){
f += f/8388608.0;
}else{
f -= f/8388608.0;
}
f = (float)(d*(d<0 ? RNDAWAY : RNDTOWARDS));
}
return f;
}
@ -2760,11 +2762,7 @@ static RtreeValue rtreeValueUp(sqlite3_value *v){
double d = sqlite3_value_double(v);
float f = (float)d;
if( f<d ){
if( f<0.0 ){
f -= f/8388608.0;
}else{
f += f/8388608.0;
}
f = (float)(d*(d<0 ? RNDTOWARDS : RNDAWAY));
}
return f;
}