• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ IntType函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IntType函数的典型用法代码示例。如果您正苦于以下问题:C++ IntType函数的具体用法?C++ IntType怎么用?C++ IntType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: main

main( )
{
    Rational X;
    Rational Sum = 0;
    Rational Max = 0;
    int N = 0;

    cout << "Type as many rational numbers as you want\n";

    while( cin >> X )
    {
        cout << "Read " << X << '\n';
        Sum += X;
        if( X > Max )
            Max = X;
        N++;
    }
    cout << "Read " << N << " rationals\n";
    if( Max > IntType( 0 ) )
        cout << "Largest positive number is " << Max << '\n';
    if( N > 0 )
        cout << "Average is " << Sum / IntType( N ) << '\n';

    return 0;
}
开发者ID:chadadavis,项目名称:junk,代码行数:25,代码来源:RATMAIN.CPP


示例2: Round2

inline IntType Round2(FloatType Number)
{
    if ((Number - (FloatType)floor(double(Number))) < 0.5)
        return IntType(floor(double(Number)));
    else
        return IntType(ceil(double(Number)));
}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:7,代码来源:InlineUtils.hpp


示例3: str_to_int_impl

		inline SPROUT_CONSTEXPR IntType
		str_to_int_impl(CStrIterator str, int base, bool negative) {
			return *str == static_cast<typename std::iterator_traits<CStrIterator>::value_type>('0')
				? *sprout::next(str) == static_cast<typename std::iterator_traits<CStrIterator>::value_type>('x')
					|| *sprout::next(str) == static_cast<typename std::iterator_traits<CStrIterator>::value_type>('X')
					? sprout::detail::str_to_int_impl_1<IntType>(
						sprout::next(str, 2),
						base ? base : 16,
						IntType(),
						sprout::detail::char_to_int<IntType>(*sprout::next(str, 2), base ? base : 16),
						negative
						)
					: sprout::detail::str_to_int_impl_1<IntType>(
						sprout::next(str),
						base ? base : 8,
						IntType(),
						sprout::detail::char_to_int<IntType>(*sprout::next(str), base ? base : 8),
						negative
						)
				: sprout::detail::str_to_int_impl_1<IntType>(
					str,
					base ? base : 10,
					IntType(),
					sprout::detail::char_to_int<IntType>(*str, base ? base : 10),
					negative
					)
				;
		}
开发者ID:osyo-manga,项目名称:Sprout,代码行数:28,代码来源:str_to_int.hpp


示例4: BOOST_AUTO_TEST_CASE_TEMPLATE

BOOST_AUTO_TEST_CASE_TEMPLATE(test_mult64, IntType, int64_types) {
    typedef boost::random::const_mod<IntType, INT64_C(2147483563652738498)> const_mod_type;
    BOOST_CHECK_EQUAL((const_mod_type::mult(0, 0)), IntType(0));
    BOOST_CHECK_EQUAL((const_mod_type::mult(0, 2147483562)), IntType(0));
    BOOST_CHECK_EQUAL((const_mod_type::mult(2147483562, 0)), IntType(0));
    BOOST_CHECK_EQUAL((const_mod_type::mult(2147483562, 2147483562)), IntType(INT64_C(316718521754730848)));
    BOOST_CHECK_EQUAL((const_mod_type::mult(1234567890, 1234657890)), IntType(INT64_C(1524268986129152100)));
    BOOST_CHECK_EQUAL((const_mod_type::mult(INT64_C(1234567890726352938), INT64_C(1234657890736453927))), IntType(INT64_C(88656187017794672)));
}
开发者ID:AlexanderGarmash,项目名称:boost-ndk,代码行数:9,代码来源:test_const_mod.cpp


示例5: IntType

inline SPROUT_CONSTEXPR sprout::rational<IntType>
operator/(sprout::rational<IntType> const& lhs, sprout::rational<IntType> const& rhs) {
    return rhs.numerator() == IntType(0) ? throw sprout::bad_rational()
           : lhs.numerator() == IntType(0) ? lhs
           : sprout::detail::rational_div_impl(
               lhs, rhs,
               sprout::gcd(lhs.numerator(), rhs.numerator()),
               sprout::gcd(rhs.denominator(), lhs.denominator())
           )
           ;
}
开发者ID:EzoeRyou,项目名称:Sprout,代码行数:11,代码来源:arithmetic.hpp


示例6: ascii_to_int

		inline SPROUT_CONSTEXPR typename std::enable_if<
			std::is_unsigned<IntType>::value,
			IntType
		>::type
		ascii_to_int(CStrIterator str) {
			return sprout::ascii::isspace(*str)
				? sprout::detail::ascii_to_int<IntType>(sprout::next(str))
				: *str == static_cast<typename std::iterator_traits<CStrIterator>::value_type>('+')
				? sprout::detail::ascii_to_int_impl<IntType>(sprout::next(str), IntType(), false)
				: sprout::detail::ascii_to_int_impl<IntType>(str, IntType(), false)
				;
		}
开发者ID:EzoeRyou,项目名称:Sprout,代码行数:12,代码来源:ascii_to_int.hpp


示例7: ascii_to_int

		inline SPROUT_CONSTEXPR typename std::enable_if<
			sprout::is_unsigned<IntType>::value,
			IntType
		>::type
		ascii_to_int(NullTerminatedIterator const& str) {
			typedef typename std::iterator_traits<NullTerminatedIterator>::value_type value_type;
			return sprout::ascii::isspace(*str)
				? sprout::detail::ascii_to_int<IntType>(sprout::next(str))
				: *str == SPROUT_CHAR_LITERAL('+', value_type)
				? sprout::detail::ascii_to_int_impl<IntType>(sprout::next(str), IntType(), false)
				: sprout::detail::ascii_to_int_impl<IntType>(str, IntType(), false)
				;
		}
开发者ID:dnovick,项目名称:Sprout,代码行数:13,代码来源:ascii_to_int.hpp


示例8: seed_one_int

			inline SPROUT_CXX14_CONSTEXPR IntType
			seed_one_int(Sseq& seq) {
				typedef typename sprout::random::detail::seed_log<IntType, m>::type log_t;
				typedef typename sprout::random::detail::seed_k<IntType, m, log_t::value>::type k_t;
				sprout::array<std::uint_least32_t, log_t::value / 32 + 4> arr{{}};
				seq.generate(arr.begin(), arr.begin() + (k_t::value + 3));
				IntType s = 0;
				for (int j = 0; j < k_t::value; ++j) {
					IntType digit = sprout::random::detail::const_mod<IntType, m>::apply(IntType(arr[j + 3]));
					IntType mult = IntType(1) << 32 * j;
					s = sprout::random::detail::const_mod<IntType, m>::mult_add(mult, digit, s);
				}
				return s;
			}
开发者ID:EzoeRyou,项目名称:Sprout,代码行数:14,代码来源:seed_impl.hpp


示例9: seed_one_int_impl

			inline SPROUT_CONSTEXPR IntType
			seed_one_int_impl(Array const& arr, IntType s, int j) {
				return j < k ? sprout::random::detail::seed_one_int_impl<IntType, m, k>(
						arr,
						sprout::random::detail::const_mod<IntType, m>::mult_add(
							IntType(1) << 32 * j,
							sprout::random::detail::const_mod<IntType, m>::apply(IntType(arr[j + 3])),
							s
							),
						j + 1
						)
					: s
					;
			}
开发者ID:EzoeRyou,项目名称:Sprout,代码行数:14,代码来源:seed_impl.hpp


示例10: int_to_char

		inline SPROUT_CONSTEXPR Elem
		int_to_char(IntType val, int base) {
			return SPROUT_ASSERT(2 <= base && base <= 36), SPROUT_ASSERT(IntType(0) <= val && val < static_cast<IntType>(base)),
				val < 10 ? static_cast<Elem>('0') + val
					: static_cast<Elem>('a') + (val - 10)
				;
		}
开发者ID:EzoeRyou,项目名称:Sprout,代码行数:7,代码来源:char_conversion.hpp


示例11: zero

void rational<IntType>::normalize()
{
    // Avoid repeated construction
    IntType zero(0);

    if (den == zero)
        throw bad_rational();

    // Handle the case of zero separately, to avoid division by zero
    if (num == zero) {
        den = IntType(1);
        return;
    }

    IntType g = gcd<IntType>(num, den);

    num /= g;
    den /= g;

    // Ensure that the denominator is positive
    if (den < zero) {
        num = -num;
        den = -den;
    }
}
开发者ID:bsmr-games,项目名称:Privateer-Gemini-Gold,代码行数:25,代码来源:rational.hpp


示例12: abs

	inline SPROUT_CONSTEXPR sprout::rational<IntType>
	abs(sprout::rational<IntType> const& x) {
		return x.numerator() >= IntType(0) ? x
			: sprout::detail::rational_construct_access<IntType>::raw_construct(
				-x.numerator(), x.denominator()
				)
			;
	}
开发者ID:Fadis,项目名称:Sprout,代码行数:8,代码来源:values.hpp


示例13: IntType

IntType IntType::deserialize(BinaryRefReader& brr)
{
   auto type_code = brr.get_uint8_t();
   if (type_code != INTTYPE_CODE)
      BtcUtils::throw_type_error(INTTYPE_CODE, type_code);

   return IntType(brr.get_var_int());
}
开发者ID:achow101,项目名称:BitcoinArmory,代码行数:8,代码来源:DataObject.cpp


示例14: get_one_int_impl

			inline SPROUT_CONSTEXPR IntType
			get_one_int_impl(InputIterator first, InputIterator last, IntType s, int j) {
				return j < k
					? first != last
						? sprout::random::detail::get_one_int_impl<IntType, m, k>(
							sprout::next(first), last,
							sprout::random::detail::const_mod<IntType, m>::mult_add(
								IntType(1) << 32 * j,
								sprout::random::detail::const_mod<IntType, m>::apply(IntType(*first)),
								s
								),
							j + 1
							)
						: throw std::invalid_argument("Not enough elements in call to seed.")
					: s
					;
			}
开发者ID:EzoeRyou,项目名称:Sprout,代码行数:17,代码来源:seed_impl.hpp


示例15:

bool rational<IntType>::operator> (param_type i) const
{
    // Trap equality first
    if (num == i && den == IntType(1))
        return false;

    // Otherwise, we can use operator<
    return !operator<(i);
}
开发者ID:bsmr-games,项目名称:Privateer-Gemini-Gold,代码行数:9,代码来源:rational.hpp


示例16: LessThan

 bool LessThan(Random& r, IntType p0, IntType c, IntType q,
               UniformInteger<IntType, bits>& j) {
   for (int k = 0;; ++k) {
     if (j.   LessThanEqual(r,   - p0, c)) return false;
     if (j.GreaterThanEqual(r, q - p0, c)) return true;
     p0 = (p0 << bits) - IntType(Digit(r,k)) * q;
     c <<= bits;
   }
 }
开发者ID:23119841,项目名称:openbr,代码行数:9,代码来源:RandomNumber.hpp


示例17: IntType

	inline SPROUT_NON_CONSTEXPR std::basic_istream<Elem, Traits>&
	operator>>(std::basic_istream<Elem, Traits>& lhs, sprout::rational<IntType>& rhs) {
		IntType n = IntType(0);
		IntType d = IntType(1);
		Elem c = 0;
		sprout::detail::io::ios_flags_saver saver(lhs);
		lhs >> n;
		c = lhs.get();
		if (c != Elem('/')) {
			lhs.clear(std::istream::badbit);
		}
		lhs >> std::noskipws;
		lhs >> d;
		if (lhs) {
			rhs.assign(n, d);
		}
		return lhs;
	}
开发者ID:LoliGothick,项目名称:Sprout,代码行数:18,代码来源:io.hpp


示例18: operator

 result_type operator()() {
   // calculating the range every time may seem wasteful.  However, this
   // makes the information locally available for the optimizer.
   result_type range = max()-min()+1;
   int j = k*IntType(y-min())/range;
   // assert(0 <= j && j < k);
   y = v[j];
   v[j] = _rng();
   return y;
 }
开发者ID:metashell,项目名称:headers,代码行数:10,代码来源:shuffle_output.hpp


示例19: rational_less_impl_2

		inline SPROUT_CONSTEXPR bool
		rational_less_impl_2(
			sprout::rational<IntType> const& lhs, sprout::rational<IntType> const& rhs,
			IntType d1, IntType q1, IntType r1,
			IntType d2, IntType q2, IntType r2,
			unsigned reverse = 0
			)
		{
			return q1 != q2 ? reverse ? q1 > q2 : q1 < q2
				: r1 == IntType(0) || r2 == IntType(0)
					? r1 == r2 ? false
					: (r1 != IntType(0)) != static_cast<bool>(reverse ^ 1)
				: sprout::detail::rational_less_impl_2(
					lhs, rhs,
					r1, d1 / r1, d1 % r1,
					r2, d2 / r2, d2 % r2,
					reverse ^ 1
					)
				;
		}
开发者ID:LoliGothick,项目名称:Sprout,代码行数:20,代码来源:comparison.hpp


示例20: ovalue_at

			inline SPROUT_CONSTEXPR sprout::tuples::tuple<IntType, bool> ovalue_at(std::size_t i) {
				return i < 8
					? sprout::tuples::tuple<IntType, bool>(
						static_cast<IntType>(sprout::weed::detail::ovalues<void>::value[i]),
						true
						)
					: sprout::tuples::tuple<IntType, bool>(
						IntType(),
						false
						)
					;
			}
开发者ID:kundor,项目名称:Sprout,代码行数:12,代码来源:odigits.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IntUnregister函数代码示例发布时间:2022-05-30
下一篇:
C++ IntToString函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap