Documentation ¶
Index ¶
- Constants
- Variables
- type BigDec
- func MaxBigDec(d1, d2 BigDec) BigDec
- func MinBigDec(d1, d2 BigDec) BigDec
- func MustNewBigDecFromStr(s string) BigDec
- func NewBigDec(i int64) BigDec
- func NewBigDecFromBigInt(i *big.Int) BigDec
- func NewBigDecFromBigIntWithPrec(i *big.Int, prec int64) BigDec
- func NewBigDecFromDec(d sdk.Dec) BigDec
- func NewBigDecFromInt(i sdk.Int) BigDec
- func NewBigDecFromIntWithPrec(i sdk.Int, prec int64) BigDec
- func NewBigDecFromStr(str string) (BigDec, error)
- func NewBigDecWithPrec(i, prec int64) BigDec
- func OneBigDec() BigDec
- func ZeroBigDec() BigDec
- func (d BigDec) Abs() BigDec
- func (d BigDec) Add(d2 BigDec) BigDec
- func (d BigDec) AddMut(d2 BigDec) BigDec
- func (d BigDec) BigInt() *big.Int
- func (d BigDec) Ceil() BigDec
- func (d BigDec) Clone() BigDec
- func (d BigDec) Dec() sdk.Dec
- func (d BigDec) DecRoundUp() sdk.Dec
- func (d BigDec) Equal(d2 BigDec) bool
- func (d BigDec) Format(s fmt.State, verb rune)
- func (d BigDec) GT(d2 BigDec) bool
- func (d BigDec) GTE(d2 BigDec) bool
- func (d BigDec) IsInteger() bool
- func (d BigDec) IsNegative() bool
- func (d BigDec) IsNil() bool
- func (d BigDec) IsPositive() bool
- func (d BigDec) IsZero() bool
- func (d BigDec) LT(d2 BigDec) bool
- func (d BigDec) LTE(d2 BigDec) bool
- func (d BigDec) Marshal() ([]byte, error)
- func (d BigDec) MarshalAmino() ([]byte, error)
- func (d BigDec) MarshalJSON() ([]byte, error)
- func (d BigDec) MarshalTo(data []byte) (n int, err error)
- func (d BigDec) MarshalYAML() (interface{}, error)
- func (d BigDec) Mul(d2 BigDec) BigDec
- func (d BigDec) MulInt(i sdk.Int) BigDec
- func (d BigDec) MulInt64(i int64) BigDec
- func (d BigDec) MulInt64Mut(i int64) BigDec
- func (d BigDec) MulIntMut(i sdk.Int) BigDec
- func (d BigDec) MulMut(d2 BigDec) BigDec
- func (d BigDec) MulRoundUp(d2 BigDec) BigDec
- func (d BigDec) MulRoundUpMut(d2 BigDec) BigDec
- func (d BigDec) MulTruncate(d2 BigDec) BigDec
- func (d BigDec) MulTruncateMut(d2 BigDec) BigDec
- func (d BigDec) Neg() BigDec
- func (d BigDec) Power(power uint64) BigDec
- func (d BigDec) PowerMut(power uint64) BigDec
- func (d BigDec) Quo(d2 BigDec) BigDec
- func (d BigDec) QuoInt(i sdk.Int) BigDec
- func (d BigDec) QuoInt64(i int64) BigDec
- func (d BigDec) QuoInt64Mut(i int64) BigDec
- func (d BigDec) QuoIntMut(i sdk.Int) BigDec
- func (d BigDec) QuoMut(d2 BigDec) BigDec
- func (d BigDec) QuoRoundUp(d2 BigDec) BigDec
- func (d BigDec) QuoRoundUpMut(d2 BigDec) BigDec
- func (d BigDec) QuoTruncate(d2 BigDec) BigDec
- func (d BigDec) QuoTruncateMut(d2 BigDec) BigDec
- func (d BigDec) Size() int
- func (d BigDec) Sqrt() BigDec
- func (d BigDec) SqrtMut() BigDec
- func (d BigDec) String() string
- func (d BigDec) Sub(d2 BigDec) BigDec
- func (d BigDec) SubMut(d2 BigDec) BigDec
- func (d BigDec) Truncate() BigDec
- func (d BigDec) TruncateInt() sdk.Int
- func (d *BigDec) Unmarshal(data []byte) error
- func (d *BigDec) UnmarshalAmino(bz []byte) error
- func (d *BigDec) UnmarshalJSON(bz []byte) error
Constants ¶
const ( // Precision is the number of decimal places Precision = 36 // DecimalPrecisionBits is the number of bits required to represent // the above precision // Ceiling[Log2[10^Precision - 1]] DecimalPrecisionBits = 120 )
Variables ¶
var ( ErrEmptyDecimalStr = errors.New("decimal string cannot be empty") ErrInvalidDecimalLength = errors.New("invalid decimal length") ErrInvalidDecimalStr = errors.New("invalid decimal string") )
Decimal errors
Functions ¶
This section is empty.
Types ¶
type BigDec ¶
type BigDec struct {
// contains filtered or unexported fields
}
func MustNewBigDecFromStr ¶
func NewBigDecFromBigInt ¶
NewBigDecFromBigInt creates a new BigDec from big integer assuming whole numbers CONTRACT: prec <= Precision
func NewBigDecFromBigIntWithPrec ¶
NewBigDecFromBigIntWithPrec creates a new BigDec from big integer assuming whole numbers CONTRACT: prec <= Precision
func NewBigDecFromDec ¶
func NewBigDecFromInt ¶
NewBigDecFromInt creates a new BigDec from big integer assuming whole numbers CONTRACT: prec <= Precision
func NewBigDecFromIntWithPrec ¶
NewBigDecFromIntWithPrec creates a new BigDec from big integer with decimal place at prec CONTRACT: prec <= Precision
func NewBigDecFromStr ¶
NewBigDecFromStr creates a decimal from an input decimal string. valid must come in the form:
(-) whole integers (.) decimal integers
examples of acceptable input include:
-123.456 456.7890 345 -456789
NOTE - An error will return if more decimal places are provided in the string than the constant Precision.
CONTRACT - This function does not mutate the input str.
func NewBigDecWithPrec ¶
NewBigDecWithPrec creates a new BigDec from integer with decimal place at prec CONTRACT: prec <= Precision
func ZeroBigDec ¶
func ZeroBigDec() BigDec
func (BigDec) Ceil ¶
Ceil returns the smallest interger value (as a decimal) that is greater than or equal to the given decimal.
func (BigDec) DecRoundUp ¶
func (BigDec) IsNegative ¶
func (BigDec) IsPositive ¶
func (BigDec) MarshalAmino ¶
func (BigDec) MarshalJSON ¶
MarshalJSON marshals the decimal
func (BigDec) MarshalYAML ¶
MarshalYAML returns the YAML representation.
func (BigDec) MulInt64Mut ¶
MulInt64Mut - multiplication with int64
func (BigDec) MulRoundUp ¶
func (BigDec) MulRoundUpMut ¶
func (BigDec) MulTruncate ¶
func (BigDec) MulTruncateMut ¶
func (BigDec) QuoInt64Mut ¶
QuoInt64Mut - quotient with int64
func (BigDec) QuoRoundUp ¶
func (BigDec) QuoRoundUpMut ¶
func (BigDec) QuoTruncate ¶
func (BigDec) QuoTruncateMut ¶
func (BigDec) TruncateInt ¶
TruncateInt truncates the decimals from the number and returns an Int
func (*BigDec) UnmarshalAmino ¶
func (*BigDec) UnmarshalJSON ¶
UnmarshalJSON defines custom decoding scheme