Documentation ¶
Overview ¶
Package decint provides utility functions to parse and represent decimal values as integers with a set precision.
The functions in this package are typically used to store and retrieve small currency values without loss of precision.
Safe decimal values are limited up to 2^53 / 1e+6 = 9_007_199_254.740_992.
Index ¶
Examples ¶
Constants ¶
const ( // MaxInt is the maximum integer number that can be safely represented (2^53). MaxInt = 9_007_199_254_740_992 // MaxFloat is the maximum float number that can be safely represented (2^53 / 1e+06). MaxFloat = 9_007_199_254.740_992 )
Variables ¶
This section is empty.
Functions ¶
func FloatToInt ¶
FloatToInt Converts the value to a int64 representation.
func FloatToUint ¶
FloatToUint Converts the value to a uint64 representation. Negative values are converted to zero.
func IntToFloat ¶
IntToFloat Converts back the int64 representation into a float value.
func IntToString ¶
IntToString format the int64 representation as string.
func StringToInt ¶
StringToInt parse the input string float value and returns the int64 representation.
func StringToUint ¶
StringToUint parse the input string float value and returns the uint64 representation. Negative values are converted to zero.
func UintToFloat ¶
UintToFloat Converts back the uint64 representation into a float value.
func UintToString ¶
UintToString format the uint64 representation as string.
Types ¶
This section is empty.