diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:56:06 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:56:06 +0000 |
commit | 77b9dbc2d18f270f521bc25dd15bcfe847146298 (patch) | |
tree | 94052f761681e80e64768b850a51b36376072799 /apt-pkg/contrib | |
parent | cf58a7e1baf5e7d65b26f600631f355e14f802f0 (diff) |
Floating point error. Bug #64394
Author: jgg
Date: 2000-06-05 04:22:25 GMT
Floating point error. Bug #64394
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r-- | apt-pkg/contrib/progress.cc | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc index 0f2218f3c..dfa978485 100644 --- a/apt-pkg/contrib/progress.cc +++ b/apt-pkg/contrib/progress.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: progress.cc,v 1.8 1998/10/02 04:39:53 jgg Exp $ +// $Id: progress.cc,v 1.9 2000/06/05 04:22:25 jgg Exp $ /* ###################################################################### OpProgress - Operation Progress @@ -33,7 +33,10 @@ OpProgress::OpProgress() : Current(0), Total(0), Size(0), SubTotal(1), percent of Total SubTotal is. */ void OpProgress::Progress(unsigned long Cur) { - Percent = (Current + Cur/((float)SubTotal)*Size)*100.0/Total; + if (Total == 0 || Size == 0 || SubTotal == 0) + Percent = 0; + else + Percent = (Current + Cur/((float)SubTotal)*Size)*100.0/Total; Update(); } /*}}}*/ @@ -48,7 +51,10 @@ void OpProgress::OverallProgress(unsigned long Current, unsigned long Total, this->Size = Size; this->Op = Op; SubOp = string(); - Percent = Current*100.0/Total; + if (Total == 0) + Percent = 0; + else + Percent = Current*100.0/Total; Update(); } /*}}}*/ @@ -59,7 +65,10 @@ void OpProgress::SubProgress(unsigned long SubTotal,string Op) { this->SubTotal = SubTotal; SubOp = Op; - Percent = Current*100.0/Total; + if (Total == 0) + Percent = 0; + else + Percent = Current*100.0/Total; Update(); } /*}}}*/ @@ -69,7 +78,10 @@ void OpProgress::SubProgress(unsigned long SubTotal,string Op) void OpProgress::SubProgress(unsigned long SubTotal) { this->SubTotal = SubTotal; - Percent = Current*100.0/Total; + if (Total == 0) + Percent = 0; + else + Percent = Current*100.0/Total; Update(); } /*}}}*/ |