From 0b5e329a8ba2461ccb7017d3adfc972f9dccd830 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 13 Dec 2017 21:51:52 +0100 Subject: deal with floats without old-style cast We have no speed problem with handling floats/doubles in our progress handling, but that shouldn't prevent us from cleaning up the handling slightly to avoid unclean casting to ints. Reported-By: gcc -Wdouble-promotion -Wold-style-cast --- apt-pkg/contrib/progress.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'apt-pkg/contrib/progress.cc') diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc index 7c5b15e6b..5499f0946 100644 --- a/apt-pkg/contrib/progress.cc +++ b/apt-pkg/contrib/progress.cc @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -44,7 +45,7 @@ void OpProgress::Progress(unsigned long long Cur) if (Total == 0 || Size == 0 || SubTotal == 0) Percent = 0; else - Percent = (Current + Cur/((float)SubTotal)*Size)*100.0/Total; + Percent = (Current + Cur/((double)SubTotal)*Size)*100.0/Total; Update(); } /*}}}*/ @@ -106,7 +107,7 @@ bool OpProgress::CheckChange(float Interval) return true; } - if ((int)LastPercent == (int)Percent) + if (std::lround(LastPercent) == std::lround(Percent)) return false; LastPercent = Percent; -- cgit v1.2.3