From: Wolfgang Bangerth Date: Wed, 29 Jul 2015 21:41:25 +0000 (-0500) Subject: Fix division by zero. X-Git-Tag: v8.4.0-rc2~703^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=959df468f23e3d13286fa468542f0b5f52542357;p=dealii.git Fix division by zero. Instead of first dividing by zero and then cleaning up the mess, simply test whether we're going to divide by zero and do the right thing based on that test. --- diff --git a/source/base/timer.cc b/source/base/timer.cc index f5680f43ff..1e187d6bc5 100644 --- a/source/base/timer.cc +++ b/source/base/timer.cc @@ -506,10 +506,10 @@ TimerOutput::print_summary () const out_stream << i->second.total_cpu_time << "s |"; out_stream << std::setw(10); out_stream << std::setprecision(2); - double value = i->second.total_cpu_time/total_cpu_time * 100; - if (!numbers::is_finite(value)) - value = 0.0; - out_stream << value << "% |"; + if (total_cpu_time != 0) + out_stream << i->second.total_cpu_time/total_cpu_time * 100 << "% |"; + else + out_stream << 0.0 << "% |"; } out_stream << std::endl << "+---------------------------------+-----------+"