diff --git a/decimal.go b/decimal.go index 0d2425f..ec18233 100644 --- a/decimal.go +++ b/decimal.go @@ -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 diff --git a/decimal_test.go b/decimal_test.go index ecfb5ad..14a6aab 100644 --- a/decimal_test.go +++ b/decimal_test.go @@ -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)