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

Method Cmp

decimal.go:1300–1311  ·  view source on GitHub ↗

Cmp compares the numbers represented by d and d2 and returns: -1 if d < d2 0 if d == d2 +1 if d > d2

(d2 Decimal)

Source from the content-addressed store, hash-verified

1298// 0 if d == d2
1299// +1 if d > d2
1300func (d Decimal) Cmp(d2 Decimal) int {
1301 d.ensureInitialized()
1302 d2.ensureInitialized()
1303
1304 if d.exp == d2.exp {
1305 return d.value.Cmp(d2.value)
1306 }
1307
1308 rd, rd2 := RescalePair(d, d2)
1309
1310 return rd.value.Cmp(rd2.value)
1311}
1312
1313// Compare compares the numbers represented by d and d2 and returns:
1314//

Callers 15

DivRoundMethod · 0.95
CompareMethod · 0.95
EqualMethod · 0.95
GreaterThanMethod · 0.95
GreaterThanOrEqualMethod · 0.95
LessThanMethod · 0.95
LessThanOrEqualMethod · 0.95
LessMethod · 0.80
TestNewFromBigRatFunction · 0.80
TestCopyFunction · 0.80

Calls 2

ensureInitializedMethod · 0.95
RescalePairFunction · 0.85

Tested by 15

LessMethod · 0.64
TestNewFromBigRatFunction · 0.64
TestCopyFunction · 0.64
TestDecimal_QuoRemFunction · 0.64
TestDecimal_QuoRem2Function · 0.64
TestDecimal_DivRoundFunction · 0.64
TestDecimal_DivRound2Function · 0.64
TestDecimal_Abs1Function · 0.64
TestDecimal_Abs2Function · 0.64
TestDecimal_Cmp1Function · 0.64