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


C++ IntType函数代码示例

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


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


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