From 65d674a9d2cf91d04ce8cb796d0e51a5c9bfba5d Mon Sep 17 00:00:00 2001 From: oetiker Date: Wed, 19 Aug 2009 07:47:07 +0000 Subject: [PATCH] backport from 1.4 round the index of the PERCENT selected element git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.3/program@1896 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_graph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 1ccbdf8..1505d5f 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -4624,7 +4624,7 @@ int vdef_calc( array[step] = data[step * src->ds_cnt]; } qsort(array, step, sizeof(double), vdef_percent_compar); - field = (steps - 1) * dst->vf.param / 100; + field = round((dst->vf.param * (double)(steps - 1)) / 100.0); dst->vf.val = array[field]; dst->vf.when = 0; /* no time component */ free(array); @@ -4633,7 +4633,7 @@ int vdef_calc( printf("DEBUG: %3li:%10.2f %c\n", step, array[step], step == field ? '*' : ' '); #endif - } + } break; case VDEF_MAXIMUM: step = 0; -- 2.30.2