本文整理汇总了Golang中github.com/shopspring/decimal.Decimal.Mul方法的典型用法代码示例。如果您正苦于以下问题:Golang Decimal.Mul方法的具体用法?Golang Decimal.Mul怎么用?Golang Decimal.Mul使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/shopspring/decimal.Decimal
的用法示例。
在下文中一共展示了Decimal.Mul方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: genConvert
func (c *Converter) genConvert(value decimal.Decimal, from, to Currency, at *time.Time) (decimal.Decimal, error) {
var t time.Time
if at == nil {
t = time.Now().UTC()
} else {
t = *at
}
var usd decimal.Decimal
if from == USD {
usd = value
} else {
fromRate, err := c.ex.Get(t, from)
if err != nil {
return decimal.Zero, err
}
usd = value.Mul(fromRate.ToUSD)
}
if to == USD {
return usd, nil
}
toRate, err := c.ex.Get(t, to)
if err != nil {
return decimal.Zero, err
}
return usd.Mul(toRate.FromUSD), nil
}
示例2: Calculate
func (irrf *IRRF) Calculate(grossSalary decimal.Decimal) decimal.Decimal {
for _, irrfInterval := range irrf.irrfRange {
if grossSalary.Cmp(irrfInterval.Lower) >= 0 && grossSalary.Cmp(irrfInterval.Upper) <= 0 {
return grossSalary.Mul(irrfInterval.Aliquot).Sub(irrfInterval.Deduction)
}
}
lastIRRFInterval := irrf.irrfRange[len(irrf.irrfRange)-1]
return grossSalary.Mul(lastIRRFInterval.Aliquot).Sub(lastIRRFInterval.Deduction)
}
示例3: Calculate
func (inss *INSS) Calculate(grossSalary decimal.Decimal) decimal.Decimal {
for _, inssInterval := range inss.inssRange {
if grossSalary.Cmp(inssInterval.Lower) >= 0 && grossSalary.Cmp(inssInterval.Upper) <= 0 {
return grossSalary.Mul(inssInterval.Aliquot)
}
}
lastINSSInterval := inss.inssRange[len(inss.inssRange)-1]
return lastINSSInterval.Upper.Mul(lastINSSInterval.Aliquot)
}
示例4: Calculate
func (f fakeCalculator) Calculate(d decimal.Decimal) decimal.Decimal {
return d.Mul(rebatePercentage)
}
示例5: Calculate
func (dep *Dependent) Calculate(quantity decimal.Decimal) decimal.Decimal {
return quantity.Mul(dep.deduction)
}
示例6: newton
func newton(z, x decimal.Decimal) decimal.Decimal {
return z.Sub(z.Mul(z).Sub(x).Div(Const2.Mul(z)))
}
示例7: MultiplyDecimalWithoutNew
func MultiplyDecimalWithoutNew(decimalStartFloat, decimalFactor decimal.Decimal) (calculated decimal.Decimal) {
calculated = decimalStartFloat.Mul(decimalFactor)
return
}