SQLite

Check-in [f607ad27c1]
Login

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

Overview
Comment:Refactor the float-to-double rounding routines so that they compile without warnings.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | rtree-32bit-rounding
Files: files | file ages | folders
SHA1: f607ad27c1ede27af24dbee10ca867c8f7761ee3
User & Date: drh 2012-05-29 00:30:43.635
Context
2012-05-29
00:39
In the RTree module, make sure all double-to-float conversions round in a direction to increase the size of element bounding boxes. (check-in: 0abdc2903d user: drh tags: trunk)
00:30
Refactor the float-to-double rounding routines so that they compile without warnings. (Closed-Leaf check-in: f607ad27c1 user: drh tags: rtree-32bit-rounding)
2012-05-28
20:16
Simplification to the coordinate rounding logic in RTree. (check-in: df24072de2 user: drh tags: rtree-32bit-rounding)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/rtree/rtree.c.
2735
2736
2737
2738
2739
2740
2741






2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
  }else{
    nodeRelease(pRtree, pRoot);
  }

  return rc;
}







#if !defined(SQLITE_RTREE_INT_ONLY)
/*
** Convert an sqlite3_value into an RtreeValue (presumably a float)
** while taking care to round toward negative or positive, respectively.
*/
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;
    }
  }
  return f;
}
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;
    }
  }
  return f;
}
#endif /* !defined(SQLITE_RTREE_INT_ONLY) */


/*







>
>
>
>
>
>









|
<
<
<
<







|
<
<
<
<







2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757




2758
2759
2760
2761
2762
2763
2764
2765




2766
2767
2768
2769
2770
2771
2772
  }else{
    nodeRelease(pRtree, pRoot);
  }

  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)
** while taking care to round toward negative or positive, respectively.
*/
static RtreeValue rtreeValueDown(sqlite3_value *v){
  double d = sqlite3_value_double(v);
  float f = (float)d;
  if( f>d ){
    f = (float)(d*(d<0 ? RNDAWAY : RNDTOWARDS));




  }
  return f;
}
static RtreeValue rtreeValueUp(sqlite3_value *v){
  double d = sqlite3_value_double(v);
  float f = (float)d;
  if( f<d ){
    f = (float)(d*(d<0 ? RNDTOWARDS : RNDAWAY));




  }
  return f;
}
#endif /* !defined(SQLITE_RTREE_INT_ONLY) */


/*