Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Exclude max from range for xbt::random::uniform_real.
[simgrid.git] / src / xbt / random.cpp
index beaaf21..22d7591 100644 (file)
@@ -55,7 +55,7 @@ double uniform_real(double min, double max)
   }
 
   // This reuses Boost's uniform real distribution ideas
-  constexpr unsigned long divisor = decltype(mt19937_gen)::max() - decltype(mt19937_gen)::min();
+  constexpr unsigned long divisor = decltype(mt19937_gen)::max() - decltype(mt19937_gen)::min() + 1;
   unsigned long numerator         = mt19937_gen() - decltype(mt19937_gen)::min();
   return min + (max - min) * numerator / divisor;
 }