droplet

package
v0.0.0-...-4a7a8e8 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Exponent is the number of decimal places held by droplets
	Exponent = 6
	// Multiplier is how much to multiply coins by to get droplets
	Multiplier = 1e6
)

Variables

View Source
var (
	// ErrNegativeValue is returned if a balance string is a negative number
	ErrNegativeValue = errors.New("Droplet string conversion failed: Negative balance")
	// ErrTooManyDecimals is returned if a balance string has more than 6 decimal places
	ErrTooManyDecimals = errors.New("Droplet string conversion failed: Too many decimal places")
	// ErrTooLarge is returned if a balance string is greater than math.MaxInt64
	ErrTooLarge = errors.New("Droplet string conversion failed: Value is too large")
)

Functions

func FromString

func FromString(b string) (uint64, error)

FromString converts a skycoin balance string with decimal places to uint64 droplets. For example, "123.000456" becomes 123000456

func ToString

func ToString(n uint64) (string, error)

ToString converts droplets to a skycoin balance fixed-point decimal string. String will always have a decimal precision of droplet.Exponent (6). For example, 123000456 becomes "123.000456" and 123000000 becomes "123.000000".

Types

This section is empty.

Jump to

Keyboard shortcuts

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