1 ///////////////////////////////////////////////////////////////
2 // Copyright 2012 John Maddock. Distributed under the Boost
3 // Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
7 // Compare arithmetic results using fixed_int to GMP results.
11 # define _SCL_SECURE_NO_WARNINGS
15 #include <boost/multiprecision/cpp_int.hpp>
19 using namespace boost::multiprecision;
21 boost::uint64_t i = (std::numeric_limits<boost::uint64_t>::max)();
22 boost::uint64_t j = 1;
27 // Start by performing arithmetic on 64-bit integers to yield 128-bit results:
29 std::cout << std::hex << std::showbase << i << std::endl;
30 std::cout << std::hex << std::showbase << add(ui128, i, j) << std::endl;
31 std::cout << std::hex << std::showbase << multiply(ui128, i, i) << std::endl;
33 // The try squaring a 128-bit integer to yield a 256-bit result:
35 ui128 = (std::numeric_limits<uint128_t>::max)();
36 std::cout << std::hex << std::showbase << multiply(ui256, ui128, ui128) << std::endl;
50 0xFFFFFFFFFFFFFFFE0000000000000001
51 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00000000000000000000000000000001