From 756454f0fc1cc591787da1c41f0ea015f8d28381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Spjelkavik?= Date: Fri, 14 Aug 2009 11:12:15 +0000 Subject: [PATCH] Made floating point tests equal to test in old code --- uniquepoints.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/uniquepoints.c b/uniquepoints.c index 5bab33f1..a57072ff 100644 --- a/uniquepoints.c +++ b/uniquepoints.c @@ -90,17 +90,15 @@ static int uniquify(int n, double *list, double tolerance) double val = list[pos++];/* Keep first value */ for (i=1; i tolerance){ val = list[i]; list[pos++] = val; } } /* Keep last value (one way or the other...) */ - if (val + tolerance < list[n-1]){ - list[pos-1] = list[n-1]; - } - + list[pos-1] = list[n-1]; + return pos; } @@ -141,12 +139,12 @@ static int assignPointNumbers(int begin, } /* Find next k such that zlist[k] < z[i] < zlist[k+1] */ - while ((k < end) && (zlist[k] + tolerance < z[i])){ + while ((k < end) && (z[i] - zlist[k] > tolerance)){ k++; } /* assert (k < len && z[i] - zlist[k] <= tolerance) */ - if ((k == end) || ( zlist[k] + tolerance < z[i])){ + if ((k == end) || ( z[i] - zlist[k] > tolerance)){ fprintf(stderr, "Cannot associate zcorn values with given list\n"); fprintf(stderr, "of z-coordinates to given tolerance\n"); return 0;