Documentation ¶
Overview ¶
Package currency contains utility functions for currencies.
Index ¶
Examples ¶
Constants ¶
View Source
const PenniesInDollar float64 = 100
PenniesInDollar represents that there are 100 pennies in a dollar
Variables ¶
This section is empty.
Functions ¶
func DollarsToPennies ¶
DollarsToPennies converts a floating point value in dollars to pennies. If `roundUp` is true any fractional value that is less than 1 penny will be rounded up and added as an additional penny, eg 13.001 -> 1301. If the dollars amount is negative, and there is a fractional amount remaining and roundUp is true, the fractional amount will be rounded to a penny and added negatively to the output value, eg (-13.001 -> -1301). Otherwise, if roundUp is false, that value will be discarded.
Example ¶
fmt.Println(DollarsToPennies(19.136, true))
Output: 1914
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.