Documentation ¶
Overview ¶
Package amount provides utilities for converting numbers to/from the format used internally to digitalbits-core.
digitalbits-core represents asset "amounts" as 64-bit integers, but to enable fractional units of an asset, frontier, the client-libraries and other built on top of digitalbits-core use a convention, encoding amounts as a string of decimal digits with up to seven digits of precision in the fractional portion. For example, an amount shown as "101.001" in frontier would be represented in digitalbits-core as 1010010000.
Index ¶
Constants ¶
const (
One = 10000000
)
One is the value of one whole unit of currency. DigitalBits uses 7 fixed digits for fractional values, thus One is 10 million (10^7).
Variables ¶
This section is empty.
Functions ¶
func IntStringToAmount ¶
IntStringToAmount converts string integer value and converts it to digitalbits "amount". In other words, it divides the given string integer value by 10^7 and returns the string representation of that number. It is safe to use with values exceeding int64 limits.
func Parse ¶
Parse parses the provided as a digitalbits "amount", i.e. a 64-bit signed integer that represents a decimal number with 7 digits of significance in the fractional portion of the number, and returns a xdr.Int64.
func ParseInt64 ¶
ParseInt64 parses the provided as a digitalbits "amount", i.e. a 64-bit signed integer that represents a decimal number with 7 digits of significance in the fractional portion of the number.
func StringFromInt64 ¶
StringFromInt64 returns an "amount string" from the provided raw int64 value `v`.
Types ¶
This section is empty.