From 1d25c9f7c20326031dab6373713180a628fc0f83 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@1896 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_graph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/program/src/rrd_graph.c b/program/src/rrd_graph.c index 1ccbdf87..1505d5f7 100644 --- a/program/src/rrd_graph.c +++ b/program/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