roundoff bug corrected with std::round