1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright 2012 John Maddock.
3 // Copyright Christopher Kormanyos 2013. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_MP_UTYPE_HELPER_HPP
9 #define BOOST_MP_UTYPE_HELPER_HPP
12 #include <boost/cstdint.hpp>
15 namespace multiprecision {
17 template <const unsigned>
20 typedef boost::uint64_t exact;
23 struct utype_helper<0U>
25 typedef boost::uint8_t exact;
28 struct utype_helper<1U>
30 typedef boost::uint8_t exact;
33 struct utype_helper<2U>
35 typedef boost::uint8_t exact;
38 struct utype_helper<3U>
40 typedef boost::uint8_t exact;
43 struct utype_helper<4U>
45 typedef boost::uint8_t exact;
48 struct utype_helper<5U>
50 typedef boost::uint8_t exact;
53 struct utype_helper<6U>
55 typedef boost::uint8_t exact;
58 struct utype_helper<7U>
60 typedef boost::uint8_t exact;
63 struct utype_helper<8U>
65 typedef boost::uint8_t exact;
69 struct utype_helper<9U>
71 typedef boost::uint16_t exact;
74 struct utype_helper<10U>
76 typedef boost::uint16_t exact;
79 struct utype_helper<11U>
81 typedef boost::uint16_t exact;
84 struct utype_helper<12U>
86 typedef boost::uint16_t exact;
89 struct utype_helper<13U>
91 typedef boost::uint16_t exact;
94 struct utype_helper<14U>
96 typedef boost::uint16_t exact;
99 struct utype_helper<15U>
101 typedef boost::uint16_t exact;
104 struct utype_helper<16U>
106 typedef boost::uint16_t exact;
110 struct utype_helper<17U>
112 typedef boost::uint32_t exact;
115 struct utype_helper<18U>
117 typedef boost::uint32_t exact;
120 struct utype_helper<19U>
122 typedef boost::uint32_t exact;
125 struct utype_helper<20U>
127 typedef boost::uint32_t exact;
130 struct utype_helper<21U>
132 typedef boost::uint32_t exact;
135 struct utype_helper<22U>
137 typedef boost::uint32_t exact;
140 struct utype_helper<23U>
142 typedef boost::uint32_t exact;
145 struct utype_helper<24U>
147 typedef boost::uint32_t exact;
150 struct utype_helper<25U>
152 typedef boost::uint32_t exact;
155 struct utype_helper<26U>
157 typedef boost::uint32_t exact;
160 struct utype_helper<27U>
162 typedef boost::uint32_t exact;
165 struct utype_helper<28U>
167 typedef boost::uint32_t exact;
170 struct utype_helper<29U>
172 typedef boost::uint32_t exact;
175 struct utype_helper<30U>
177 typedef boost::uint32_t exact;
180 struct utype_helper<31U>
182 typedef boost::uint32_t exact;
185 struct utype_helper<32U>
187 typedef boost::uint32_t exact;
191 struct utype_helper<33U>
193 typedef boost::uint64_t exact;
196 struct utype_helper<34U>
198 typedef boost::uint64_t exact;
201 struct utype_helper<35U>
203 typedef boost::uint64_t exact;
206 struct utype_helper<36U>
208 typedef boost::uint64_t exact;
211 struct utype_helper<37U>
213 typedef boost::uint64_t exact;
216 struct utype_helper<38U>
218 typedef boost::uint64_t exact;
221 struct utype_helper<39U>
223 typedef boost::uint64_t exact;
226 struct utype_helper<40U>
228 typedef boost::uint64_t exact;
231 struct utype_helper<41U>
233 typedef boost::uint64_t exact;
236 struct utype_helper<42U>
238 typedef boost::uint64_t exact;
241 struct utype_helper<43U>
243 typedef boost::uint64_t exact;
246 struct utype_helper<44U>
248 typedef boost::uint64_t exact;
251 struct utype_helper<45U>
253 typedef boost::uint64_t exact;
256 struct utype_helper<46U>
258 typedef boost::uint64_t exact;
261 struct utype_helper<47U>
263 typedef boost::uint64_t exact;
266 struct utype_helper<48U>
268 typedef boost::uint64_t exact;
271 struct utype_helper<49U>
273 typedef boost::uint64_t exact;
276 struct utype_helper<50U>
278 typedef boost::uint64_t exact;
281 struct utype_helper<51U>
283 typedef boost::uint64_t exact;
286 struct utype_helper<52U>
288 typedef boost::uint64_t exact;
291 struct utype_helper<53U>
293 typedef boost::uint64_t exact;
296 struct utype_helper<54U>
298 typedef boost::uint64_t exact;
301 struct utype_helper<55U>
303 typedef boost::uint64_t exact;
306 struct utype_helper<56U>
308 typedef boost::uint64_t exact;
311 struct utype_helper<57U>
313 typedef boost::uint64_t exact;
316 struct utype_helper<58U>
318 typedef boost::uint64_t exact;
321 struct utype_helper<59U>
323 typedef boost::uint64_t exact;
326 struct utype_helper<60U>
328 typedef boost::uint64_t exact;
331 struct utype_helper<61U>
333 typedef boost::uint64_t exact;
336 struct utype_helper<62U>
338 typedef boost::uint64_t exact;
341 struct utype_helper<63U>
343 typedef boost::uint64_t exact;
346 struct utype_helper<64U>
348 typedef boost::uint64_t exact;
351 template <class unsigned_type>
352 int utype_prior(unsigned_type ui)
354 // TBD: Implement a templated binary search for this.
357 unsigned_type priority_mask = unsigned_type(unsigned_type(1U) << (std::numeric_limits<unsigned_type>::digits - 1));
359 for (priority_bit = std::numeric_limits<unsigned_type>::digits - 1; priority_bit >= 0; --priority_bit)
361 if (unsigned_type(priority_mask & ui) != unsigned_type(0U))
372 }}} // namespace boost::multiprecision::detail
374 #endif // BOOST_MP_UTYPE_HELPER_HPP