예제 #1
0
// Reset implements the protobuf marshalling interface.
func (q *Quantity) Unmarshal(data []byte) error {
	p := QuantityProto{}
	if err := p.Unmarshal(data); err != nil {
		return err
	}
	q.Format = p.Format
	b := big.NewInt(0)
	b.SetBytes(p.Bigint)
	q.Amount = inf.NewDecBig(b, inf.Scale(p.Scale))
	return nil
}
예제 #2
0
// infScale adapts a Scale value to an inf.Scale value.
func (s Scale) infScale() inf.Scale {
	return inf.Scale(-s) // inf.Scale is upside-down
}