[postgis-tickets] [PostGIS] #3929: Unexpected rounding from ST_SnapToGrid

PostGIS trac at osgeo.org
Sat Dec 2 17:21:08 PST 2017


#3929: Unexpected rounding from ST_SnapToGrid
-----------------------+---------------------------
  Reporter:  michaudm  |      Owner:  pramsey
      Type:  defect    |     Status:  closed
  Priority:  medium    |  Milestone:  PostGIS 2.4.2
 Component:  postgis   |    Version:  2.4.x
Resolution:  wontfix   |   Keywords:
-----------------------+---------------------------

Comment (by pramsey):

 Good thought, but it seems to not make the difference we want in C world.
 {{{
 static void test_rint()
 {
     char str[] = "311.4";
     double d1, d2, d3;
     double g = 0.1;

     sscanf(str, "%lf", &d1);
     printf("d1: %g\n", d1);

     d2 = rint(d1 / g) * g;
     printf("d2: %g\n", d2);
     printf("d2-d1: %g\n", d2-d1);

     d3 = round(d1 / g) * g;
     printf("d3-d1: %g\n", d3-d1);
 }
 }}}

 {{{
 d1: 311.4
 d2: 311.4
 d2-d1: 5.68434e-14
 d3-d1: 5.68434e-14
 }}}

--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3929#comment:3>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list