Package denary64 provides a base-10 floating point number type, for the Go programming language.
Base-10 floating point numbers are safe to use to store money values, and are safe to do math calculations with on money values.
This is as opposed to the built-in Golang types float32
, and float64
which are base-2 floating point number types (rather than base-10) and which are NOT safe to use for money values.
Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-denary64
import "github.com/reiver/go-denary64"
x := denary64.Parse("12000.42")
y := denary64.Parse("7.00")
z := x.Add(y)
fmt.Printf("x + y = z", x, y, z)
// Output: 12000.42 + 7 = 12007.42