func EncodeStringNumber(value string) ([]byte, error) { if strings.Count(value, ".") > 0 { number, ok := big.NewDecimal(value) if !ok { return nil, Error("couldn't create a big.Decimal representation of " + value) } return EncodeBigDecimal(number), nil } number, ok := new(big.Int).SetString(value, 10) if !ok { return nil, Error("couldn't create an big.Int representation of " + value) } return EncodeBigInt(number), nil }
func WriteNumber(value string, buffer *bytes.Buffer) os.Error { if strings.Count(value, ".") > 0 { number, ok := big.NewDecimal(value) if !ok { return EncodingError("Couldn't create a Decimal representation of " + value) } WriteDecimal(number, buffer) return nil } number, ok := new(big.Int).SetString(value, 10) if !ok { return EncodingError("Couldn't create an Int representation of " + value) } WriteBigInt(number, buffer) return nil }
func decimal(value string) *big.Decimal { dec, _ := big.NewDecimal(value) return dec }