Skip to content

Instantly share code, notes, and snippets.

@maliqq
Created July 23, 2013 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maliqq/6063741 to your computer and use it in GitHub Desktop.
Save maliqq/6063741 to your computer and use it in GitHub Desktop.
import (
"math"
)
type Currency struct {
Name string // "US Dollar"
IsoCode string // "USD"
Precision int // 2
}
type Money struct {
Value int64
*Currency
}
func (m Money) Float64() float64 {
return float64(m.Value) / math.Pow10(m.Precision)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment