MCPcopy
hub / github.com/shopspring/decimal / Mul

Method Mul

decimal.go:558–574  ·  view source on GitHub ↗

Mul returns d * d2.

(d2 Decimal)

Source from the content-addressed store, hash-verified

556
557// Mul returns d * d2.
558func (d Decimal) Mul(d2 Decimal) Decimal {
559 d.ensureInitialized()
560 d2.ensureInitialized()
561
562 expInt64 := int64(d.exp) + int64(d2.exp)
563 if expInt64 > math.MaxInt32 || expInt64 < math.MinInt32 {
564 // NOTE(vadim): better to panic than give incorrect results, as
565 // Decimals are usually used for money
566 panic(fmt.Sprintf("exponent %v overflows an int32!", expInt64))
567 }
568
569 d3Value := new(big.Int).Mul(d.value, d2.value)
570 return Decimal{
571 value: d3Value,
572 exp: int32(expInt64),
573 }
574}
575
576// Shift shifts the decimal in base 10.
577// It shifts left when shift is positive and right if shift is negative.

Callers 15

LnMethod · 0.95
RoundCashMethod · 0.95
xatanMethod · 0.95
SinMethod · 0.95
CosMethod · 0.95
TanMethod · 0.95
TestDecimal_MulFunction · 0.80
TestDecimal_QuoRemFunction · 0.80
createDivTestCasesFunction · 0.80

Calls 1

ensureInitializedMethod · 0.95

Tested by 10

TestDecimal_MulFunction · 0.64
TestDecimal_QuoRemFunction · 0.64
createDivTestCasesFunction · 0.64
TestDecimal_QuoRem2Function · 0.64
TestDecimal_DivRoundFunction · 0.64
TestDecimal_DivRound2Function · 0.64
TestDecimal_OverflowFunction · 0.64