currency

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2019 License: MIT Imports: 3 Imported by: 4

Documentation

Overview

Package currency provides library functions for manipulating token balances

Units

Taking inspiration from the SI units, we have suitable multiples:

1/ 1 000 000 000 000 000 000 atto (a) 10^-18 1/ 1 000 000 000 000 000 femto (f) 10^-15 1/ 1 000 000 000 000 pico (p) 10^-12 1/ 1 000 000 000 nano (n) 10^-9 1/ 1 000 000 micro (u) 10^-6 1/ 1 000 milli (m) 10^-3 1 Token (T) 1 All letters are lowercase except for T for Token

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandAndSeparateCurrencyString

func ExpandAndSeparateCurrencyString(input string) string

ExpandAndSeparateCurrencyString expands the input string, then applies comma separators

func ExpandCurrencyString

func ExpandCurrencyString(input string) string

ExpandCurrencyString takes a string with a token suffix and expands it with the appropriate number of zeroes. The input string may contain a decimal point, and it will expand it, standard form style. By conventtion hex balances have a leading 0x, decimals are bare. THis function will work correctly with either. This function returns Attoms.

func FormatCurrencyString

func FormatCurrencyString(input string) string

FormatCurrencyString ...

func FormatTokenString added in v0.3.3

func FormatTokenString(input string) string

FormatTokenString is a wrapper to FormatUnitString

func FormatUnitString added in v0.3.3

func FormatUnitString(input string, power int) string

FormatUnitString takes an atomic input and returns

Types

This section is empty.

Jump to

Keyboard shortcuts

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