diff --git a/apps/statistics/histogram_controller.cpp b/apps/statistics/histogram_controller.cpp index cb302ce5b..b26b33c39 100644 --- a/apps/statistics/histogram_controller.cpp +++ b/apps/statistics/histogram_controller.cpp @@ -247,9 +247,14 @@ void HistogramController::initBarParameters() { assert(selectedSeriesIndex() >= 0 && m_store->sumOfOccurrences(selectedSeriesIndex()) > 0); preinitXRangeParameters(); m_store->setFirstDrawnBarAbscissa(m_store->xMin()); - float barWidth = m_store->xGridUnit(); - if (barWidth <= 0.0f) { - barWidth = 1.0f; + double barWidth = m_store->xGridUnit(); + if (barWidth <= 0.0) { + barWidth = 1.0; + } else { + // Truncate the bar width, as we convert from float to double + const double precision = 7; // TODO factorize? This is an experimental value, the same as in Expression;;Epsilon() + const double logBarWidth = std::floor(std::log10(barWidth)); + barWidth = ((int)(barWidth * std::pow(10.0, precision - logBarWidth))) * std::pow(10.0, -precision + logBarWidth); } m_store->setBarWidth(barWidth); }