Documentation ¶
Overview ¶
Package math provides helper functions for doing mathematical calculations and parsing for the ecocredit module.
Index ¶
- func Add(res, x, y *apd.Decimal) error
- func DecimalString(x *apd.Decimal) string
- func NumDecimalPlaces(x *apd.Decimal) uint32
- func ParseNonNegativeDecimal(x string) (*apd.Decimal, error)
- func ParseNonNegativeFixedDecimal(x string, maxDecimalPlaces uint32) (*apd.Decimal, error)
- func ParsePositiveDecimal(x string) (*apd.Decimal, error)
- func ParsePositiveFixedDecimal(x string, maxDecimalPlaces uint32) (*apd.Decimal, error)
- func SafeSub(res, x, y *apd.Decimal) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add(res, x, y *apd.Decimal) error
Add adds x and y and stores the result in res with arbitrary precision or returns an error.
func DecimalString ¶
func DecimalString(x *apd.Decimal) string
DecimalString prints x as a floating point string.
func NumDecimalPlaces ¶
func NumDecimalPlaces(x *apd.Decimal) uint32
NumDecimalPlaces returns the number of decimal places in x.
func ParseNonNegativeDecimal ¶
ParseNonNegativeDecimal parses a non-negative decimal or returns an error.
func ParseNonNegativeFixedDecimal ¶
ParseNonNegativeDecimal parses a non-negative decimal with a fixed maxDecimalPlaces or returns an error.
func ParsePositiveDecimal ¶
ParsePositiveDecimal parses a positive decimal or returns an error.
func ParsePositiveFixedDecimal ¶
ParsePositiveFixedDecimal parses a positive decimal with a fixed maxDecimalPlaces or returns an error.
Types ¶
This section is empty.