]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/multiprecision/detail/digits.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / multiprecision / detail / digits.hpp
CommitLineData
7c673cae
FG
1///////////////////////////////////////////////////////////////
2// Copyright 2012 John Maddock. Distributed under the Boost
3// Software License, Version 1.0. (See accompanying file
92f5a8d4 4// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
7c673cae
FG
5
6#ifndef BOOST_MP_DIGITS_HPP
7#define BOOST_MP_DIGITS_HPP
8
92f5a8d4 9namespace boost { namespace multiprecision { namespace detail {
7c673cae 10
1e59de90 11inline constexpr unsigned long digits10_2_2(unsigned long d10)
7c673cae
FG
12{
13 return (d10 * 1000uL) / 301uL + ((d10 * 1000uL) % 301 ? 2u : 1u);
14}
15
1e59de90 16inline constexpr unsigned long digits2_2_10(unsigned long d2)
7c673cae
FG
17{
18 return (d2 * 301uL) / 1000uL;
19}
20
1e59de90
TL
21
22#if ULONG_MAX != SIZE_MAX
23
24inline constexpr std::size_t digits10_2_2(std::size_t d10)
25{
26 return (d10 * 1000uL) / 301uL + ((d10 * 1000uL) % 301 ? 2u : 1u);
27}
28
29inline constexpr std::size_t digits2_2_10(std::size_t d2)
30{
31 return (d2 * 301uL) / 1000uL;
32}
33
34template <class I>
35inline constexpr typename std::enable_if<sizeof(I) <= sizeof(unsigned long), unsigned long>::type digits10_2_2(I d10)
36{
37 return digits10_2_2(static_cast<unsigned long>(d10));
38}
39
40template <class I>
41inline constexpr typename std::enable_if<sizeof(I) <= sizeof(unsigned long), unsigned long>::type digits2_2_10(I d10)
42{
43 return digits2_2_10(static_cast<unsigned long>(d10));
44}
45#endif
46
92f5a8d4 47}}} // namespace boost::multiprecision::detail
7c673cae
FG
48
49#endif