]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Verify that a number is not a NaN before testing for finiteness.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 29 Jun 2015 22:59:54 +0000 (17:59 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 30 Jun 2015 14:28:38 +0000 (09:28 -0500)
While not intuitive, std::isfinite triggers a floating point exception when called
on a signalling NaN. Avoid this.

source/base/config.cc

index a1514c74a0e1af6396f50050f96e632ff7657744..82e01557593a21eae795091eba7c69e45cc0d8bf 100644 (file)
@@ -1,6 +1,6 @@
 // ---------------------------------------------------------------------
 //
-// Copyright (C) 2006 - 2014 by the deal.II authors
+// Copyright (C) 2006 - 2015 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
@@ -25,7 +25,7 @@ namespace numbers
   bool is_finite (const double x)
   {
 #ifdef DEAL_II_HAVE_ISFINITE
-    return std::isfinite (x);
+    return !isnan(x) && std::isfinite (x);
 #else
     // Check against infinities. Note
     // that if x is a NaN, then both

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.