samedi 3 décembre 2016

Strange boost cpp_Int behaviour when using auto type deduction

I just noticed some really strange behaviour when using auto to store the result of a boost cpp_int operation

#include <boost/multiprecision/cpp_int.hpp>

int main() {
    using boost::multiprecision::cpp_int;
    cpp_int a = 1, b = 10 * a, d;
    auto c = 10 * a;
    d = c;
    std::cout << b << " " << c << " " << d << "\n";
}

which outputs:

10 0 0 

instead of:

10 10 10

can anybody explain this?

Aucun commentaire:

Enregistrer un commentaire