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


C# Money.Round方法代码示例

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


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

示例1: Round_DecimalPlaces_using_Money_RoundingMode

        public void Round_DecimalPlaces_using_Money_RoundingMode(RoundingMode roundingMode, DecimalPlaces decimalPlaces, decimal value, decimal expected)
        {
            // specify different DecimalPlaces for Money ctor to ensure the argument value is used
            Money money = new Money("ZAR", value, roundingMode, DecimalPlaces.Nine);

            Money actual = money.Round(decimalPlaces);
            Assert.That(actual.Amount == expected);
        }
开发者ID:hermanpotgieter,项目名称:MoneyAndCurrency,代码行数:8,代码来源:RoundingExtensionTests.cs

示例2: Round_RoundingMode_using_Money_DecimalPlaces

        public void Round_RoundingMode_using_Money_DecimalPlaces(RoundingMode roundingMode, DecimalPlaces decimalPlaces, decimal value, decimal expected)
        {
            // specify different RoundingMode for Money ctor to ensure the argument value is used
            RoundingMode moneyMode = roundingMode == 0 ? roundingMode + 1 : roundingMode - 1;
            Money money = new Money("ZAR", value, moneyMode, decimalPlaces);

            Money actual = money.Round(roundingMode);
            Assert.That(actual.Amount == expected);
        }
开发者ID:hermanpotgieter,项目名称:MoneyAndCurrency,代码行数:9,代码来源:RoundingExtensionTests.cs

示例3: ConvertToOrderCurrency

 /// <summary>
 /// Converts an amount to the currency of a given order.
 /// </summary>
 /// <param name="fee">The amount to convert.</param>
 /// <param name="client">The order whose currency to convert to.</param>
 /// <returns></returns>
 protected Money ConvertToOrderCurrency(Money fee, ICommClient client)
 {
     if (fee != null)
     {
         if ((ICurrency)fee.Underlying != client.OrderCurrency)
             fee = fee.Convert(client.OrderCurrency);
         return fee.Round();
     }
     else
         return new Money(0, client.OrderCurrency);
 }
开发者ID:kiquenet,项目名称:B4F,代码行数:17,代码来源:CommCalc.cs

示例4: Round_no_arguments_using_Money_defaults

 public void Round_no_arguments_using_Money_defaults(RoundingMode roundingMode, DecimalPlaces decimalPlaces, decimal value, decimal expected)
 {
     Money money = new Money("ZAR", value, roundingMode, decimalPlaces);
     Money actual = money.Round();
     Assert.That(actual.Amount == expected);
 }
开发者ID:hermanpotgieter,项目名称:MoneyAndCurrency,代码行数:6,代码来源:RoundingExtensionTests.cs

示例5: CalculateBackwards

        /// <summary>
        /// Calculates a fee so that the fee plus the net amount (of the order) equals the gross amount.
        /// </summary>
        /// <param name="grossAmount">The gross amount.</param>
        /// <param name="fee">The calculated fee (<b>out</b> parameter).</param>
        /// <returns><b>true</b> if fee could be calculated (net amount fell on this line), <b>false</b> if not.</returns>
        public virtual bool CalculateBackwards(Money grossAmount, out Money fee)
        {
            bool result = false;
            Money nettAmount;
            Money check;

            Money comAmount = grossAmount;
            if (!comAmount.Underlying.Equals(this.Parent.CommCurrency))
                comAmount = comAmount.Convert(this.Parent.CommCurrency);

            Money fixedSetup = Parent.FixedSetup + StaticChargeAmount;
            fee = (((comAmount.Abs() - fixedSetup) * (FeePercentage / 100M)) / (1M + (FeePercentage / 100M))) + fixedSetup;
            fee = fee.Round();

            check = Parent.MinValue;
            if (check != null && check.IsNotZero && fee < check)
            {
                fee = check;
            }
            else
            {
                check = Parent.MaxValue;
                if (check != null && check.IsNotZero && fee > check)
                {
                    fee = check;
                }
            }

            if (comAmount.Sign)
            {
                nettAmount = comAmount - fee;
            }
            else
            {
                nettAmount = comAmount + fee;
            }

            // Check if within range
            if (Envelops(nettAmount.Abs()))
                result = true;
            return result;
        }
开发者ID:kiquenet,项目名称:B4F,代码行数:48,代码来源:CommCalcLineAmountBased.cs


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