f8ad33e
diff --git a/math/mathcore/src/TMath.cxx b/math/mathcore/src/TMath.cxx
f8ad33e
index 942bb55..72618fc 100644
f8ad33e
--- a/math/mathcore/src/TMath.cxx
f8ad33e
+++ b/math/mathcore/src/TMath.cxx
f8ad33e
@@ -1210,7 +1210,9 @@ void TMath::Quantiles(Int_t n, Int_t nprob, Double_t *x, Double_t *quantiles, Do
f8ad33e
          else
f8ad33e
             nppm = n*prob[i]; // use m = 0
f8ad33e
 
f8ad33e
-         j = TMath::FloorNint(nppm);
f8ad33e
+         // be careful with machine precision
f8ad33e
+         double eps = 4 * TMath::Limits<Double_t>::Epsilon();
f8ad33e
+         j = TMath::FloorNint(nppm + eps);
f8ad33e
 
f8ad33e
          // LM : fix for numerical problems if nppm is actually equal to j, but results different for numerical error
f8ad33e
          // g in the paper is nppm -j