diff --git a/src/utils/math_funcs.hpp b/src/utils/math_funcs.hpp
index c862fc8875e874fff7ecd268352590958d5569c8..4394c51ded66c7e58b612784cecc8f4e959a83c7 100644
--- a/src/utils/math_funcs.hpp
+++ b/src/utils/math_funcs.hpp
@@ -751,7 +751,7 @@ void rank(const double* a, double* rank, int* index, const size_type size)
     while (ii_start < size)
     {
         while ((ii < size) && (std::abs(a[index[ii]] - a[index[ii - 1]]) <
-                               1e-10 * std::pow(10.0, std::floor(std::log10(a[index[ii]])))))
+                               1e-10 * std::pow(10.0, std::floor(std::log10(std::abs(a[index[ii]]))))))
         {
             ++ii;
         }