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


C++ Money::value方法代码示例

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


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

示例1: if

 Decimal operator/(const Money& m1, const Money& m2) {
     if (m1.currency() == m2.currency()) {
         return m1.value()/m2.value();
     } else if (Money::conversionType == Money::BaseCurrencyConversion) {
         Money tmp1 = m1;
         convertToBase(tmp1);
         Money tmp2 = m2;
         convertToBase(tmp2);
         return tmp1/tmp2;
     } else if (Money::conversionType == Money::AutomatedConversion) {
         Money tmp = m2;
         convertTo(tmp, m1.currency());
         return m1/tmp;
     } else {
         QL_FAIL("currency mismatch and no conversion specified");
     }
 }
开发者ID:SePTimO7,项目名称:QuantLib,代码行数:17,代码来源:money.cpp

示例2: close_enough

 bool close_enough(const Money& m1, const Money& m2, Size n) {
     if (m1.currency() == m2.currency()) {
         return close_enough(m1.value(),m2.value(),n);
     } else if (Money::conversionType == Money::BaseCurrencyConversion) {
         Money tmp1 = m1;
         convertToBase(tmp1);
         Money tmp2 = m2;
         convertToBase(tmp2);
         return close_enough(tmp1,tmp2,n);
     } else if (Money::conversionType == Money::AutomatedConversion) {
         Money tmp = m2;
         convertTo(tmp, m1.currency());
         return close_enough(m1,tmp,n);
     } else {
         QL_FAIL("currency mismatch and no conversion specified");
     }
 }
开发者ID:SePTimO7,项目名称:QuantLib,代码行数:17,代码来源:money.cpp

示例3: exchange

 Money ExchangeRate::exchange(const Money& amount) const {
     switch (type_) {
       case Direct:
         if (amount.currency() == source_)
             return Money(amount.value()*rate_, target_);
         else if (amount.currency() == target_)
             return Money(amount.value()/rate_, source_);
         else
             QL_FAIL("exchange rate not applicable");
       case Derived:
         if (amount.currency() == rateChain_.first->source() ||
             amount.currency() == rateChain_.first->target())
             return rateChain_.second->exchange(
                                      rateChain_.first->exchange(amount));
         else if (amount.currency() == rateChain_.second->source() ||
                    amount.currency() == rateChain_.second->target())
             return rateChain_.first->exchange(
                                      rateChain_.second->exchange(amount));
         else
             QL_FAIL("exchange rate not applicable");
       default:
         QL_FAIL("unknown exchange-rate type");
     }
 }
开发者ID:androidYibo,项目名称:documents,代码行数:24,代码来源:exchangerate.cpp


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