Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:22

0001 ///////////////////////////////////////////////////////////////
0002 //  Copyright 2019 John Maddock. Distributed under the Boost
0003 //  Software License, Version 1.0. (See accompanying file
0004 //  LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
0005 //
0006 // We used to use lexical_cast internally for quick conversions from integers 
0007 // to strings, but that breaks if the global locale is something other than "C".
0008 // See https://github.com/boostorg/multiprecision/issues/167.
0009 //
0010 #ifndef BOOST_MP_DETAIL_ITOS_HPP
0011 #define BOOST_MP_DETAIL_ITOS_HPP
0012 
0013 namespace boost { namespace multiprecision { namespace detail {
0014 
0015    template <class Integer>
0016    std::string itos(Integer val)
0017    {
0018       if (!val)  return "0";
0019       std::string result;
0020       bool isneg = false;
0021       if (val < 0)
0022       {
0023          val = -val;
0024          isneg = true;
0025       }
0026       while (val)
0027       {
0028          result.insert(result.begin(), char('0' + (val % 10)));
0029          val /= 10;
0030       }
0031       if (isneg)
0032          result.insert(result.begin(), '-');
0033       return result;
0034    }
0035 
0036 
0037 }}} // namespace boost::multiprecision::detail
0038 
0039 #endif