digits.hpp 647 B

1234567891011121314151617181920212223
  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 https://www.boost.org/LICENSE_1_0.txt
  5. #ifndef BOOST_MP_DIGITS_HPP
  6. #define BOOST_MP_DIGITS_HPP
  7. namespace boost { namespace multiprecision { namespace detail {
  8. inline unsigned long digits10_2_2(unsigned long d10)
  9. {
  10. return (d10 * 1000uL) / 301uL + ((d10 * 1000uL) % 301 ? 2u : 1u);
  11. }
  12. inline unsigned long digits2_2_10(unsigned long d2)
  13. {
  14. return (d2 * 301uL) / 1000uL;
  15. }
  16. }}} // namespace boost::multiprecision::detail
  17. #endif