From 0a90a68915d850a0af2ef6a79dd5a48bf410af79 Mon Sep 17 00:00:00 2001 From: modus75 Date: Thu, 8 Dec 2016 22:14:37 +0100 Subject: [PATCH] fixes #563 quick search filter, wrong limits on upper range limit --- include/functions_search.inc.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php index 59fc97cac..407fef4f1 100644 --- a/include/functions_search.inc.php +++ b/include/functions_search.inc.php @@ -389,15 +389,21 @@ class QNumericRangeScope extends QSearchScope $val = floatval($matches[1]); if (isset($matches[2])) { + $mult = 1; if ($matches[2]=='k' || $matches[2]=='K') - { - $val *= 1000; - if ($i) $val += 999; - } - if ($matches[2]=='m' || $matches[2]=='M') - { - $val *= 1000000; - if ($i) $val += 999999; + $mult = 1000; + else + $mult = 1000000; + $val *= $mult; + if ($i && !$strict[1]) + {// round up the upper limit if possible - e.g 6k goes up to 6999, but 6.12k goes only up to 6129 + if ( ($dot_pos = strpos($matches[1], '.')) !== false ) + { + $requested_precision = strlen($matches[1]) - $dot_pos - 1; + $mult /= pow(10, $requested_precision); + } + if ($mult>1) + $val += $mult-1; } } }