From 959df468f23e3d13286fa468542f0b5f52542357 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 29 Jul 2015 16:41:25 -0500 Subject: [PATCH] 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. --- source/base/timer.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 << "+---------------------------------+-----------+" -- 2.39.5