1[/ 2 Copyright 2011 - 2020 John Maddock. 3 Copyright 2013 - 2019 Paul A. Bristow. 4 Copyright 2013 Christopher Kormanyos. 5 6 Distributed under the Boost Software License, Version 1.0. 7 (See accompanying file LICENSE_1_0.txt or copy at 8 http://www.boost.org/LICENSE_1_0.txt). 9] 10 11[section:cpp_int_ref cpp_int] 12 13 namespace boost{ namespace multiprecision{ 14 15 typedef unspecified-type limb_type; 16 17 enum cpp_integer_type { signed_magnitude, unsigned_magnitude }; 18 enum cpp_int_check_type { checked, unchecked }; 19 20 template <unsigned MinDigits = 0, 21 unsigned MaxDits = 0, 22 cpp_integer_type SignType = signed_magnitude, 23 cpp_int_check_type Checked = unchecked, 24 class Allocator = std::allocator<limb_type> > 25 class cpp_int_backend; 26 // 27 // Expression templates default to et_off if there is no allocator: 28 // 29 template <unsigned MinDigits, unsigned MaxDigits, cpp_integer_type SignType, cpp_int_check_type Checked> 30 struct expression_template_default<cpp_int_backend<MinDigits, MaxDigits, SignType, Checked, void> > 31 { static const expression_template_option value = et_off; }; 32 33 typedef number<cpp_int_backend<> > cpp_int; // arbitrary precision integer 34 typedef rational_adaptor<cpp_int_backend<> > cpp_rational_backend; 35 typedef number<cpp_rational_backend> cpp_rational; // arbitrary precision rational number 36 37 // Fixed precision unsigned types: 38 typedef number<cpp_int_backend<128, 128, unsigned_magnitude, unchecked, void> > uint128_t; 39 typedef number<cpp_int_backend<256, 256, unsigned_magnitude, unchecked, void> > uint256_t; 40 typedef number<cpp_int_backend<512, 512, unsigned_magnitude, unchecked, void> > uint512_t; 41 typedef number<cpp_int_backend<1024, 1024, unsigned_magnitude, unchecked, void> > uint1024_t; 42 43 // Fixed precision signed types: 44 typedef number<cpp_int_backend<128, 128, signed_magnitude, unchecked, void> > int128_t; 45 typedef number<cpp_int_backend<256, 256, signed_magnitude, unchecked, void> > int256_t; 46 typedef number<cpp_int_backend<512, 512, signed_magnitude, unchecked, void> > int512_t; 47 typedef number<cpp_int_backend<1024, 1024, signed_magnitude, unchecked, void> > int1024_t; 48 49 // Over again, but with checking enabled this time: 50 typedef number<cpp_int_backend<0, 0, signed_magnitude, checked> > checked_cpp_int; 51 typedef rational_adaptor<cpp_int_backend<0, 0, signed_magnitude, checked> > checked_cpp_rational_backend; 52 typedef number<checked_cpp_rational_backend> checked_cpp_rational; 53 54 // Checked fixed precision unsigned types: 55 typedef number<cpp_int_backend<128, 128, unsigned_magnitude, checked, void> > checked_uint128_t; 56 typedef number<cpp_int_backend<256, 256, unsigned_magnitude, checked, void> > checked_uint256_t; 57 typedef number<cpp_int_backend<512, 512, unsigned_magnitude, checked, void> > checked_uint512_t; 58 typedef number<cpp_int_backend<1024, 1024, unsigned_magnitude, checked, void> > checked_uint1024_t; 59 60 // Fixed precision signed types: 61 typedef number<cpp_int_backend<128, 128, signed_magnitude, checked, void> > checked_int128_t; 62 typedef number<cpp_int_backend<256, 256, signed_magnitude, checked, void> > checked_int256_t; 63 typedef number<cpp_int_backend<512, 512, signed_magnitude, checked, void> > checked_int512_t; 64 typedef number<cpp_int_backend<1024, 1024, signed_magnitude, checked, void> > checked_int1024_t; 65 66 }} // namespaces 67 68Class template `cpp_int_backend` fulfils all of the requirements for a [link boost_multiprecision.ref.backendconc Backend] type. 69Its members and non-member functions are deliberately not documented: these are considered implementation details that are subject 70to change. 71 72The template arguments are: 73 74[variablelist 75[[MinBits][Determines the number of Bits to store directly within the object before resorting to dynamic memory 76 allocation. When zero, this field is determined automatically based on how many bits can be stored 77 in union with the dynamic storage header: setting a larger value may improve performance as larger integer 78 values will be stored internally before memory allocation is required.]] 79[[MaxBits][Determines the maximum number of bits to be stored in the type: resulting in a fixed precision type. 80 When this value is the same as MinBits, then the Allocator parameter is ignored, as no dynamic 81 memory allocation will ever be performed: in this situation the Allocator parameter should be set to 82 type `void`. Note that this parameter should not be used simply to prevent large memory 83 allocations, not only is that role better performed by the allocator, but fixed precision 84 integers have a tendency to allocate all of MaxBits of storage more often than one would expect.]] 85[[SignType][Determines whether the resulting type is signed or not. Note that for 86[@http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic arbitrary precision] types 87 this parameter must be `signed_magnitude`. For fixed precision 88 types then this type may be either `signed_magnitude` or `unsigned_magnitude`.]] 89[[Checked][This parameter has two values: `checked` or `unchecked`. See the [link boost_multiprecision.tut.ints.cpp_int tutorial] for more information.]] 90[[Allocator][The allocator to use for dynamic memory allocation, or type `void` if MaxBits == MinBits.]] 91] 92 93The type of `number_category<cpp_int<Args...> >::type` is `mpl::int_<number_kind_integer>`. 94 95More information on this type can be found in the [link boost_multiprecision.tut.ints.cpp_int tutorial]. 96 97[endsect] 98