Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Using the proper c++ way to get the min double value
authorYann Duplouy <yann.duplouy@inria.fr>
Mon, 21 Oct 2019 09:55:28 +0000 (11:55 +0200)
committerYann Duplouy <yann.duplouy@inria.fr>
Mon, 21 Oct 2019 09:55:28 +0000 (11:55 +0200)
src/xbt/random.cpp

index b0f172a..03c544a 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "xbt/random.hpp"
 #include "xbt/asserts.h"
 
 #include "xbt/random.hpp"
 #include "xbt/asserts.h"
+#include <limits>
 #include <random>
 
 namespace simgrid {
 #include <random>
 
 namespace simgrid {
@@ -52,7 +53,7 @@ double normal(double mean, double sd)
   unsigned long numeratorB = mt19937_gen() - mt19937_gen.min();
   unsigned long divisor    = mt19937_gen.max() - mt19937_gen.min();
   double u1                = numeratorA / divisor;
   unsigned long numeratorB = mt19937_gen() - mt19937_gen.min();
   unsigned long divisor    = mt19937_gen.max() - mt19937_gen.min();
   double u1                = numeratorA / divisor;
-  while (u1 < DBL_MIN) {
+  while (u1 < std::numeric_limits<double>::min()) {
     numeratorA = mt19937_gen() - mt19937_gen.min();
     u1         = numeratorA / divisor;
   }
     numeratorA = mt19937_gen() - mt19937_gen.min();
     u1         = numeratorA / divisor;
   }