math

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package math provides helper functions for doing mathematical calculations and parsing for the ecocredit module.

Index

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

func ParseNonNegativeDecimal(x string) (*apd.Decimal, error)

ParseNonNegativeDecimal parses a non-negative decimal or returns an error.

func ParseNonNegativeFixedDecimal

func ParseNonNegativeFixedDecimal(x string, maxDecimalPlaces uint32) (*apd.Decimal, error)

ParseNonNegativeDecimal parses a non-negative decimal with a fixed maxDecimalPlaces or returns an error.

func ParsePositiveDecimal

func ParsePositiveDecimal(x string) (*apd.Decimal, error)

ParsePositiveDecimal parses a positive decimal or returns an error.

func ParsePositiveFixedDecimal

func ParsePositiveFixedDecimal(x string, maxDecimalPlaces uint32) (*apd.Decimal, error)

ParsePositiveFixedDecimal parses a positive decimal with a fixed maxDecimalPlaces or returns an error.

func SafeSub

func SafeSub(res, x, y *apd.Decimal) error

SafeSub subtracts the value of x from y and stores the result in res with arbitrary precision only if the result will be non-negative. An insufficient funds error is returned if the result would be negative.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL