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

Method Add

decimal.go:526–534  ·  view source on GitHub ↗

Add returns d + d2.

(d2 Decimal)

Source from the content-addressed store, hash-verified

524
525// Add returns d + d2.
526func (d Decimal) Add(d2 Decimal) Decimal {
527 rd, rd2 := RescalePair(d, d2)
528
529 d3Value := new(big.Int).Add(rd.value, rd2.value)
530 return Decimal{
531 value: d3Value,
532 exp: rd.exp,
533 }
534}
535
536// Sub returns d - d2.
537func (d Decimal) Sub(d2 Decimal) Decimal {

Callers 15

LnMethod · 0.95
satanMethod · 0.95
TestCopyFunction · 0.80
TestDecimal_AddFunction · 0.80
TestDecimal_QuoRemFunction · 0.80
TestDecimal_QuoRem2Function · 0.80
NewFromFloatWithExponentFunction · 0.80
DivRoundMethod · 0.80

Calls 1

RescalePairFunction · 0.85

Tested by 8

TestCopyFunction · 0.64
TestDecimal_AddFunction · 0.64
TestDecimal_QuoRemFunction · 0.64
TestDecimal_QuoRem2Function · 0.64