当前位置: 首页>>代码示例>>C++>>正文


C++ std::ldexp方法代码示例

本文整理汇总了C++中std::ldexp方法的典型用法代码示例。如果您正苦于以下问题:C++ std::ldexp方法的具体用法?C++ std::ldexp怎么用?C++ std::ldexp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std的用法示例。


在下文中一共展示了std::ldexp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: safe_convert_to_float

R safe_convert_to_float(const LargeInteger& i)
{
   using std::ldexp;
   if(!i)
      return R(0);
   if(std::numeric_limits<R>::is_specialized && std::numeric_limits<R>::max_exponent)
   {
      LargeInteger val(i);
      if(val.sign() < 0)
         val = -val;
      unsigned mb = msb(val);
      if(mb >= std::numeric_limits<R>::max_exponent)
      {
         int scale_factor = (int)mb + 1 - std::numeric_limits<R>::max_exponent;
         BOOST_ASSERT(scale_factor >= 1);
         val >>= scale_factor;
         R result = val.template convert_to<R>();
         if(std::numeric_limits<R>::digits == 0 || std::numeric_limits<R>::digits >= std::numeric_limits<R>::max_exponent)
         {
            //
            // Calculate and add on the remainder, only if there are more
            // digits in the mantissa that the size of the exponent, in 
            // other words if we are dropping digits in the conversion
            // otherwise:
            //
            LargeInteger remainder(i);
            remainder &= (LargeInteger(1) << scale_factor) - 1;
            result += ldexp(safe_convert_to_float<R>(remainder), -scale_factor);
         }
         return i.sign() < 0 ? static_cast<R>(-result) : result;
      }
开发者ID:Niko-r,项目名称:geofeatures,代码行数:31,代码来源:generic_interconvert.hpp

示例2: test_spots

void test_spots(T)
{
   using std::ldexp;
   T tolerance = boost::math::tools::epsilon<T>() * 40000;
      BOOST_CHECK_CLOSE(
         ::boost::math::ibeta_derivative(
            static_cast<T>(2),
            static_cast<T>(4),
            ldexp(static_cast<T>(1), -557)),
         static_cast<T>(4.23957586190238472641508753637420672781472122471791800210e-167L), tolerance * 4);
      BOOST_CHECK_CLOSE(
         ::boost::math::ibeta_derivative(
            static_cast<T>(2),
            static_cast<T>(4.5),
            ldexp(static_cast<T>(1), -557)),
         static_cast<T>(5.24647512910420109893867082626308082567071751558842352760e-167L), tolerance * 4);
}
开发者ID:DenisKolodin,项目名称:math,代码行数:17,代码来源:test_ibeta_derivative.hpp

示例3: ldexp

inline
quantity<Unit, Y>
ldexp(const quantity<Unit, Y>& q,const Int& ex)
{
    using std::ldexp;

    typedef quantity<Unit,Y> quantity_type;

    return quantity_type::from_value(ldexp(q.value(), ex));
}
开发者ID:TheForum,项目名称:Earth-and-Beyond-server,代码行数:10,代码来源:cmath_boost_1_35.hpp

示例4: LatitudeResolution

 /**
  * The latitude resolution of a geohash.
  *
  * @param[in] len the length of the geohash.
  * @return the latitude resolution (degrees).
  *
  * Internally, \e len is first put in the range [0, 18].
  **********************************************************************/
 static Math::real LatitudeResolution(int len) {
   using std::ldexp;
   len = (std::max)(0, (std::min)(int(maxlen_), len));
   return ldexp(real(180), -(5 * len / 2));
 }
开发者ID:bakercp,项目名称:ofxGeographicLib,代码行数:13,代码来源:Geohash.hpp


注:本文中的std::ldexp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。