Mercurial > hg > libxtract
diff src/scalar.c @ 192:bb60691d9570
Make xtract_lowest_value() return XTRACT_NO_RESULT if all values in the input data are below or equal to threshold value. Fixes #46
If XTRACT_NO_RESULT is returned, *result will be set to DBL_MAX
author | Jamie Bullock <jamie@jamiebullock.com> |
---|---|
date | Tue, 11 Feb 2014 16:39:41 +0000 |
parents | 95af6c8dc7f2 |
children | e63fa5ad1902 |
line wrap: on
line diff
--- a/src/scalar.c Wed Jan 15 19:16:32 2014 +0000 +++ b/src/scalar.c Tue Feb 11 16:39:41 2014 +0000 @@ -27,6 +27,7 @@ #include <string.h> #include <stdio.h> #include <math.h> +#include <limits.h> #include "dywapitchtrack/dywapitchtrack.h" @@ -746,16 +747,18 @@ { int n = N; - double temp; - *result = data[--n]; + *result = DBL_MAX; while(n--) { - if((temp = data[n]) > *(double *)argv) + if(data[n] > *(double *)argv) *result = XTRACT_MIN(*result, data[n]); } + if (*result == DBL_MAX) + return XTRACT_NO_RESULT; + return XTRACT_SUCCESS; }