1 // (C) Copyright John Maddock 2007. 2 // Use, modification and distribution are subject to the 3 // Boost Software License, Version 1.0. (See accompanying file 4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 #include <boost/limits.hpp> 7 #include <vector> 8 #include "mp_t.hpp" 9 write_table(unsigned max_exponent)10void write_table(unsigned max_exponent) 11 { 12 mp_t max = ldexp(mp_t(1), (int)max_exponent); 13 14 std::vector<mp_t> factorials; 15 factorials.push_back(1); 16 17 mp_t f(1); 18 unsigned i = 1; 19 20 while(f < max) 21 { 22 factorials.push_back(f); 23 ++i; 24 f *= i; 25 } 26 27 // 28 // now write out the results to cout: 29 // 30 std::cout << std::scientific << std::setprecision(40); 31 std::cout << " static const boost::array<T, " << factorials.size() << "> factorials = {\n"; 32 for(unsigned j = 0; j < factorials.size(); ++j) 33 std::cout << " " << factorials[j] << "L,\n"; 34 std::cout << " };\n\n"; 35 } 36 37 main()38int main() 39 { 40 write_table(16384/*std::numeric_limits<float>::max_exponent*/); 41 } 42