mirror of
https://github.com/shopspring/decimal.git
synced 2024-11-23 04:40:49 +01:00
Added implementation of DigitsValue() that exposes the big.Int value part of the decimal.
This commit is contained in:
parent
af95951b3f
commit
3b7679240e
2 changed files with 13 additions and 0 deletions
|
@ -313,6 +313,12 @@ func (d Decimal) Equals(d2 Decimal) bool {
|
|||
return d.Cmp(d2) == 0
|
||||
}
|
||||
|
||||
// DigitsValue returns the integer that represents the digits of the decimal.
|
||||
// This is the value of the decimal scaled by 10^Exponent().
|
||||
func (d Decimal) DigitsValue() *big.Int {
|
||||
return d.value
|
||||
}
|
||||
|
||||
// Exponent returns the exponent, or scale component of the decimal.
|
||||
func (d Decimal) Exponent() int32 {
|
||||
return d.exp
|
||||
|
|
|
@ -885,6 +885,13 @@ func TestDecimal_Scale(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestDecimal_DigitsValue(t *testing.T) {
|
||||
a := New(1234, -3)
|
||||
if a.DigitsValue().Int64() != 1234 {
|
||||
t.Errorf("error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecimal_Abs1(t *testing.T) {
|
||||
a := New(-1234, -4)
|
||||
b := New(1234, -4)
|
||||
|
|
Loading…
Reference in a new issue