mathutil

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const TenThousands = 10000

TenThousands ...

Variables

View Source
var (
	//BigOne represents a single unit of an asset with precision 8
	BigOne = uint64(math.Pow10(8))
	//BigOneDecimal represents a single unit of an asset with precision 8 as decimal.Decimal
	BigOneDecimal = decimal.NewFromInt(int64(BigOne))
)

Functions

func Add

func Add(x, y uint64) (z decimal.Decimal)

Add takes two uint64 numbers and sum them x + y and returns the result as decimal.Decimal

func AddDecimal

func AddDecimal(X, Y decimal.Decimal) (z decimal.Decimal)

AddDecimal takes two decimal.Decimal numbers and sum them x + y and returns the result as decimal.Decimal

func BigAdd

func BigAdd(x, y int64) (z int64)

BigAdd takes two int64 numbers and sum them x + y and returns the result

func BigDiv

func BigDiv(x, y int64) (z int64)

BigDiv takes two int64 numbers and sum them x - y and returns the result

func BigMul

func BigMul(x, y int64) (z int64)

BigMul takes two int64 numbers and sum them x - y and returns the result

func BigSub

func BigSub(x, y int64) (z int64)

BigSub takes two int64 numbers and sum them x - y and returns the result

func Div

func Div(x, y uint64) (z decimal.Decimal)

Div takes two uint64 numbers and divides them x / y and returns the result as decimal.Decimal

func DivDecimal

func DivDecimal(X, Y decimal.Decimal) (z decimal.Decimal)

DivDecimal takes two decimal.Decimal numbers and divides them x / y and returns the result as decimal.Decimal

func LessFee

func LessFee(amount, feeAsBasisPoint uint64) (withFee, calculatedFee uint64)

LessFee calculates an amount with a subtracted given a int64 amount and a fee expressed in basis point (ie. 0.25 = 25)

func Mul

func Mul(x, y uint64) (z decimal.Decimal)

Mul takes two int64 numbers and multiply them x * y and returns the result as decimal.Decimal

func MulDecimal

func MulDecimal(X, Y decimal.Decimal) (z decimal.Decimal)

MulDecimal takes two decimal.Decimal numbers and multiply them x * y and returns the result as decimal.Decimal

func PlusFee

func PlusFee(amount, feeAsBasisPoint uint64) (withFee, calculatedFee uint64)

PlusFee calculates an amount with a fee added given a int64 amount and a fee expressed in basis point (ie. 0.25 = 25)

func Sub

func Sub(x, y uint64) (z decimal.Decimal)

Sub takes two uint64 numbers and subtract them x - y and returns the result as decimal.Decimal

func SubDecimal

func SubDecimal(X, Y decimal.Decimal) (z decimal.Decimal)

SubDecimal takes two decimal.Decimal numbers and subtract them x - y and returns the result as decimal.Decimal

Types

This section is empty.

Jump to

Keyboard shortcuts

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