Subject: [Boost-bugs] [Boost C++ Libraries] #11437: rolling_mean returns incorrect result when using unsigned int
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-06-30 10:55:58
#11437: rolling_mean returns incorrect result when using unsigned int
-------------------------------------+--------------------------
Reporter: Gareth White <gwhite@â¦> | Owner: eric_niebler
Type: Bugs | Status: new
Milestone: To Be Determined | Component: accumulator
Version: Boost 1.58.0 | Severity: Regression
Keywords: |
-------------------------------------+--------------------------
Using rolling_mean with a sample type of "unsigned int" leads to incorrect
results. The following example outputs 1.43166e+009 instead of the
expected 1.
{{{
#include <iostream>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/accumulators/statistics/count.hpp>
#include <boost/accumulators/statistics/rolling_mean.hpp>
using namespace boost::accumulators;
int main(int argc, char** argv)
{
accumulator_set<unsigned int, stats<tag::rolling_mean, tag::count>>
acc(tag::rolling_window::window_size = 3);
acc(3);
acc(2);
acc(1);
acc(0);
std::cout << rolling_mean(acc) << std::endl;
}
}}}
The same problem happens if the sample type is "int" but you pass unsigned
ints to the accumulator. For example, if you replace the above code with
the following code, the result is the same:
{{{
accumulator_set<int, stats<tag::rolling_mean, tag::count>>
acc(tag::rolling_window::window_size = 3);
acc(3U);
acc(2U);
acc(1U);
acc(0U);
}}}
I found this problem using Visual Studio 2010, after upgrading from Boost
1.44.0 to 1.58.0. With Boost 1.44.0, the above examples return 1.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11437> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC