Documentation ¶
Overview ¶
Package decimals is a small library of functions for rounding and formatting base ten numbers. These are functions that are either missing from the standard libraries or are more convenient for presenting numbers in a human-readable format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatFloat ¶
FormatFloat converts a float64 to a formatted string. The float is rounded to the given precision and formatted using a comma separator for thousands.
func FormatInt ¶
FormatInt converts an int64 to a formatted string. The int is rounded to the given precision and formatted using a comma separator for thousands.
func FormatThousands ¶
FormatThousands converts an int64 into a string formatted using a comma separator for thousands.
func RoundFloat ¶
RoundFloat rounds a base ten float64 to the given decimal precision. Precision may be positive, representing the number of decimal places, or negative, representing the nearest power of ten to which the float should be rounded.
func RoundInt ¶
RoundInt rounds a base ten int64 to the given precision. Precision is a negative number that represents the nearest power of ten to which the integer should be rounded. It is expressed as a negative number to be consistent with the decimal precision arguments used in rounding floats. If the rounded number falls outside the minimum and maximum for int64 the minimum or maximum will be returned instead.
Types ¶
This section is empty.