Help us shape the future of Go! Take the 2026 Go Developer Survey

math

package
v1.24.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WeiPerEth      float64 = 1e18
	WeiPerGwei     float64 = 1e9
	WeiPerMilliEth float64 = 1e15
	GweiPerEth     float64 = 1e9
)

Conversion factors

Variables

View Source
var Abs = math.Abs
View Source
var Ceil = math.Ceil
View Source
var Floor = math.Floor
View Source
var Pow = math.Pow

Functions

func EthToWei

func EthToWei(eth float64) *big.Int

Convert eth to wei

func EthToWeiWithDecimals

func EthToWeiWithDecimals(amountRaw float64, decimals uint8) *big.Int

Converts float amount to big.Int considering a token's decimals

func GetPowerOfTwoCeil

func GetPowerOfTwoCeil(x uint64) uint64

func GweiToEth

func GweiToEth(gwei uint64) float64

func GweiToWei

func GweiToWei(gwei float64) *big.Int

Convert gigawei to wei

func MilliEthToWei

func MilliEthToWei(milliEth float64) *big.Int

Convert milliEth to wei

func RoundDown

func RoundDown(val float64, places int) float64

Round a float64 down to a number of places

func RoundUp

func RoundUp(val float64, places int) float64

Round a float64 up to a number of places

func WeiToEth

func WeiToEth(wei *big.Int) float64

Convert wei to eth

func WeiToEthWithDecimals

func WeiToEthWithDecimals(amount *big.Int, decimals uint8) float64

Converts big.Int to float64 considering a token's decimals

func WeiToGwei

func WeiToGwei(wei *big.Int) float64

Convert wei to gigawei

Types

This section is empty.

Jump to

Keyboard shortcuts

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