[ create a new paste ] login | about

Link: http://codepad.org/3cSn9GkZ    [ raw code | output | fork ]

C++, pasted on Mar 5:
#include <iostream>
#include <sstream>

#include <boost/timer.hpp>
//#include <boost/xint/integer.hpp>
//#include <ttmathint.h>
//#include <cln/cln.h>
//#include <cln/integer.h>

template <typename T>
void test(std::string const& name, int count)
{
    boost::timer t;
    T m = 0;
    for (int c = 0; c < count; c++)
    {
        T v = 2;
        for (int i = 0; i < 1000; i++)
        {
            v *= 2;
            v += 4;
            if (v > m)
            {
                m = v;
            }
        }
    }

    std::cout << name 
        << ": " << t.elapsed() 
        << std::endl;
    std::cout << m << std::endl;
    std::cout << std::endl;
}

int main() 
{
    test<int>("int", 1); // just to test the program, not the results
    //test<boost::xint::integer>("xint", 1000);
    //test<cln::cl_I>("cli", 1000);
    //test<ttmath::Int<16> >("ttmath.16", 1000);
    //test<ttmath::Int<32> >("ttmath.32", 1000);
    //test<ttmath::Int<32> >("ttmath.64", 1000);

    return 0;
}


Output:
1
2
3
int: 0
2147483644



Create a new paste based on this one


Comments: