- 
                Notifications
    
You must be signed in to change notification settings  - Fork 162
 
Open
Description
Google has a Money type based on a unit and nano representation. It is used, for example, in the Publisher API to obtain prices of base plans.
Based on a quick research this seems to be based on a fixed-point approach of representing money and, according to the provided link, it seems to be a common way to store dollars for example.
I took a look at the documentation and couldn't find any way to create a money.Money instance from this kind of representation. Do you think it would make sense to support it? I'm imagining something like:
const (
	FixedPointSizeDeci  = 1
	FixedPointSizeCenti = 2
	FixedPointSizeMilli = 3
	FixedPointSizeMicro = 6
	FixedPointSizeNano  = 9
)
func NewFromFixedPoint(units int64, fraction int64, size uint64, code string) *money.Money
// Specifying 1.25€ using "nanos"
euros := money.NewFromFixedPoint(1, 250_000_000, money.FixedPointSizeNano, money.EUR)batazor
Metadata
Metadata
Assignees
Labels
No labels