summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/progress.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-12-13 21:51:52 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2017-12-13 23:53:48 +0100
commit0b5e329a8ba2461ccb7017d3adfc972f9dccd830 (patch)
tree61fe422eeca8c5bd5cb2de6060f11e71343d4602 /apt-pkg/contrib/progress.cc
parent1adcf56bec7d2127d83aa423916639740fe8e586 (diff)
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
Diffstat (limited to 'apt-pkg/contrib/progress.cc')
-rw-r--r--apt-pkg/contrib/progress.cc5
1 files changed, 3 insertions, 2 deletions
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 <apt-pkg/error.h>
#include <apt-pkg/progress.h>
+#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
@@ -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;