pgsql: Tweak "line" test to avoid negative zeros on some platforms
Tweak "line" test to avoid negative zeros on some platforms
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/a0a546f0d94ec6cbb3cd6b1c82f58d801046615f
Modified Files
--------------
src/test/regress/expected/line.out | 18 +++++++++---------
src/test/regress/sql/line.sql | 2 +-
2 files changed, 10 insertions(+), 10 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Peter Eisentraut <peter_e@gmx.net> writes:
Tweak "line" test to avoid negative zeros on some platforms
I had been playing around with that last night on a PPC-era Mac,
hoping to get rid of the problem by twiddling the expressions in
line_construct_pts(). The only thing I could find to fix it
was the brute-force approach:
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c
index 25f0bfd..41178a6 100644
--- a/src/backend/utils/adt/geo_ops.c
+++ b/src/backend/utils/adt/geo_ops.c
@@ -1116,6 +1116,9 @@ line_construct_pts(LINE *line, Point *pt1, Point *pt2)
line->A = (pt2->y - pt1->y) / (pt2->x - pt1->x);
line->B = -1.0;
line->C = pt1->y - line->A * pt1->x;
+ /* on some platforms, the preceding expression tends to produce -0 */
+ if (line->C == 0.0)
+ line->C = 0.0;
#ifdef GEODEBUG
printf("line_construct_pts- line is neither vertical nor horizontal (diffs x=%.*g, y=%.*g\n",
DBL_DIG, (pt2->x - pt1->x), DBL_DIG, (pt2->y - pt1->y));
While this is surely pretty ugly, I think it is less ugly and more robust
than what you've done here. Comments?
regards, tom lane
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
On 10/25/13, 10:55 AM, Tom Lane wrote:
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index 25f0bfd..41178a6 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -1116,6 +1116,9 @@ line_construct_pts(LINE *line, Point *pt1, Point *pt2) line->A = (pt2->y - pt1->y) / (pt2->x - pt1->x); line->B = -1.0; line->C = pt1->y - line->A * pt1->x; + /* on some platforms, the preceding expression tends to produce -0 */ + if (line->C == 0.0) + line->C = 0.0; #ifdef GEODEBUG printf("line_construct_pts- line is neither vertical nor horizontal (diffs x=%.*g, y=%.*g\n", DBL_DIG, (pt2->x - pt1->x), DBL_DIG, (pt2->y - pt1->y));While this is surely pretty ugly, I think it is less ugly and more robust
than what you've done here. Comments?
Hehe, if that work's, then yes, it's better.
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers