[GRASS-SVN] r52887 - grass/branches/develbranch_6/lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 25 04:08:54 PDT 2012
Author: mmetz
Date: 2012-08-25 04:08:53 -0700 (Sat, 25 Aug 2012)
New Revision: 52887
Modified:
grass/branches/develbranch_6/lib/gis/color_write.c
Log:
libgis: fix r52184
Modified: grass/branches/develbranch_6/lib/gis/color_write.c
===================================================================
--- grass/branches/develbranch_6/lib/gis/color_write.c 2012-08-25 11:07:59 UTC (rev 52886)
+++ grass/branches/develbranch_6/lib/gis/color_write.c 2012-08-25 11:08:53 UTC (rev 52887)
@@ -247,10 +247,16 @@
double dtmp;
sprintf(str, "%.15g", dval);
+ /* Note that G_trim_decimal() does not trim e.g. 1.0000000e-20 */
G_trim_decimal(str);
sscanf(str, "%lf", &dtmp);
- if (dtmp != dval) /* if no zeros after decimal point were trimmed */
- sprintf(str, "%.15g", dval - GRASS_EPSILON);
+ if (dtmp != dval) { /* if no zeros after decimal point were trimmed */
+ /* lower dval by fraction of GRASS_EPSILON */
+ if (dval > 0)
+ sprintf(str, "%.15g", dval * (1 - GRASS_EPSILON));
+ else
+ sprintf(str, "%.15g", dval * (1 + GRASS_EPSILON));
+ }
return 0;
}
@@ -260,10 +266,16 @@
double dtmp;
sprintf(str, "%.15g", dval);
+ /* Note that G_trim_decimal() does not trim e.g. 1.0000000e-20 */
G_trim_decimal(str);
sscanf(str, "%lf", &dtmp);
- if (dtmp != dval) /* if no zeros after decimal point were trimmed */
- sprintf(str, "%.15g", dval + GRASS_EPSILON);
+ if (dtmp != dval) { /* if no zeros after decimal point were trimmed */
+ /* increase dval by fraction of GRASS_EPSILON */
+ if (dval > 0)
+ sprintf(str, "%.15g", dval * (1 + GRASS_EPSILON));
+ else
+ sprintf(str, "%.15g", dval * (1 - GRASS_EPSILON));
+ }
return 0;
}
More information about the grass-commit
mailing list