]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use a standard method to find whether a number is normal. 973/head
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 28 May 2015 20:37:37 +0000 (15:37 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 28 May 2015 20:37:37 +0000 (15:37 -0500)
In the current context, this slightly changes the behavior in that the new
condition also catches infinities, rather than just NaNs as before, but the
downstream code will still yield the same answers.

include/deal.II/base/logstream.h

index 6d6720ffad8bb04d4b46db2c9d7cbee3d7222e65..577f9dc691ff52fd37d8900517b6ab85f3d6b3a9 100644 (file)
@@ -1,6 +1,6 @@
 // ---------------------------------------------------------------------
 //
-// Copyright (C) 1998 - 2014 by the deal.II authors
+// Copyright (C) 1998 - 2015 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
@@ -594,11 +594,10 @@ LogStream::operator<< (const double t)
 {
   std::ostringstream &stream = get_stream();
 
+  // drop small numbers or skew them away from zero.
   // we have to make sure that we don't catch NaN's and +-Inf's with the
   // test, because for these denormals all comparisons are always false.
-  // thus, for a NaN, both t<=0 and t>=0 are false at the same time, which
-  // can't be said for any other number
-  if (! (t<=0) && !(t>=0))
+  if (! numbers::is_finite(t))
     stream << t;
   else if (std::fabs(t) < double_threshold)
     stream << '0';

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.