当前位置: 首页>>代码示例>>Golang>>正文


Golang strconv.Ftoa64函数代码示例

本文整理汇总了Golang中strconv.Ftoa64函数的典型用法代码示例。如果您正苦于以下问题:Golang Ftoa64函数的具体用法?Golang Ftoa64怎么用?Golang Ftoa64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Ftoa64函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Zrangebyscore

func (self *client) Zrangebyscore(key string, start float64, end float64) ([][]byte, os.Error) {
	res, err := self.sendCommand("ZRANGEBYSCORE", key, strconv.Ftoa64(start, 'f', -1), strconv.Ftoa64(end, 'f', -1))
	if err != nil {
		return nil, err
	}

	return res.([][]byte), nil
}
开发者ID:ysimonson,项目名称:redis.go,代码行数:8,代码来源:redis.go

示例2: Sell

// Sell opens a new order to sell BTC.
func Sell(c appengine.Context, login xgen.Credentials, price float64, amount float64) (x xgen.OpenOrders, err os.Error) {
	defer func() {
		if e, ok := recover().(os.Error); ok {
			err = e
		}
	}()
	var openOrders OpenOrders
	err = restapi.PostJson(c, JsonSell, map[string][]string{"name": {login.Username}, "pass": {login.Password},
		"price": {strconv.Ftoa64(price, 'f', -1)}, "amount": {strconv.Ftoa64(amount, 'f', -1)}}, &openOrders)
	check(err)
	x = openOrders.convert()
	return
}
开发者ID:adrianuswarmenhoven,项目名称:ArBit,代码行数:14,代码来源:tradehillapi.go

示例3: SaveState

func (s *Splitter) SaveState() os.Error {
	buf := bytes.NewBuffer(nil)

	count := s.children.Len()
	layout := s.Layout().(*splitterLayout)

	for i := 0; i < count; i += 2 {
		if i > 0 {
			buf.WriteString(" ")
		}

		buf.WriteString(strconv.Ftoa64(layout.fractions[i/2], 'f', -1))
	}

	s.putState(buf.String())

	for _, widget := range s.children.items {
		if persistable, ok := widget.(Persistable); ok {
			if err := persistable.SaveState(); err != nil {
				return err
			}
		}
	}

	return nil
}
开发者ID:wiloe,项目名称:walk,代码行数:26,代码来源:splitter.go

示例4: atos

// any to string
func atos(i interface{}) (s string) {
	switch t := i.(type) {
	case int64:
		s = strconv.Itoa64(t)
	case uint64:
		s = strconv.Uitoa64(t)
	case float32:
		s = strconv.Ftoa32(t, 'f', -1)
	case float64:
		s = strconv.Ftoa64(t, 'f', -1)
	case []byte:
		s = string(t)
	case Date:
		return t.String()
	case Time:
		return t.String()
	case DateTime:
		return t.String()
	case string:
		return t
	default:
		panic("Not a string or compatible type")
	}
	return
}
开发者ID:sudheesh001,项目名称:nodejs,代码行数:26,代码来源:convert.go

示例5: enc

func enc(val reflect.Value, typ reflect.Type, buffer *bytes.Buffer, req bool) (encoded bool, err os.Error) {
	switch typ.(type) {
	case *reflect.PtrType:
		// log.Println("pointer")
		pt := typ.(*reflect.PtrType).Elem()
		pv := reflect.Indirect(val)
		// log.Println("Type is: ", pt.Name())
		if pv == nil {
			if !req {
				return false, nil
			} else {
				return false, os.NewError("Required field is nil")
			}
		}
		return enc(pv, pt, buffer, req)
	case *reflect.BoolType:
		if val.(*reflect.BoolValue).Get() {
			buffer.WriteString("true")
		} else {
			buffer.WriteString("false")
		}
	case *reflect.IntType:
		buffer.WriteString(strconv.Itoa64(val.(*reflect.IntValue).Get()))
	case *reflect.UintType:
		buffer.WriteString(strconv.Uitoa64(val.(*reflect.UintValue).Get()))
	case *reflect.StringType:
		buffer.WriteString("\"")
		// TODO: encode
		buffer.WriteString(val.(*reflect.StringValue).Get())
		buffer.WriteString("\"")
	case *reflect.FloatType:
		buffer.WriteString(strconv.Ftoa64(val.(*reflect.FloatValue).Get(), 'e', -1))
	case *reflect.StructType:
		enc_struct(val.(*reflect.StructValue), typ.(*reflect.StructType), buffer)
	case *reflect.SliceType:
		st := typ.(*reflect.SliceType).Elem()
		sv := val.(*reflect.SliceValue)
		if sv.IsNil() {
			if req {
				return false, os.NewError("Required field is nil")
			} else {
				return false, nil
			}
		}
		buffer.WriteString("[")
		for i := 0; i < sv.Len(); i++ {
			if i > 0 {
				buffer.WriteString(",")
			}
			_, err := enc(sv.Elem(i), st, buffer, true)
			if err != nil {
				return false, err
			}
		}
		buffer.WriteString("]")
	default:
		return false, os.NewError("Unsupported type")
	}
	return true, nil
}
开发者ID:AaronO,项目名称:lightwave,代码行数:60,代码来源:jsonprotobuf.go

示例6: AsString

func AsString(v interface{}) (string, os.Error) {
	switch value := v.(type) {
	default:
		return "", os.NewError(fmt.Sprintf("unexpected type: %T", value))
	case int:
		return strconv.Itoa(value), nil
	case int8:
		return strconv.Itoa(int(value)), nil
	case int16:
		return strconv.Itoa(int(value)), nil
	case int32:
		return strconv.Itoa(int(value)), nil
	case int64:
		return strconv.Itoa64(value), nil
	case uint:
		return strconv.Uitoa(value), nil
	case uint8:
		return strconv.Uitoa(uint(value)), nil
	case uint16:
		return strconv.Uitoa(uint(value)), nil
	case uint32:
		return strconv.Uitoa(uint(value)), nil
	case uint64:
		return strconv.Uitoa64(value), nil
	case float32:
		return strconv.Ftoa32(value, 'g', -1), nil
	case float64:
		return strconv.Ftoa64(value, 'g', -1), nil
	case string:
		return value, nil
	}
	panic(fmt.Sprintf("unsupported type: %s", reflect.ValueOf(v).Type().Name()))
}
开发者ID:thomaslee,项目名称:go-ext,代码行数:33,代码来源:conversions.go

示例7: main

func main() {
	ir, err := gothic.NewInterpreter()
	if err != nil {
		panic(err)
	}

	feet := ir.NewStringVar("feet")
	meters := ir.NewStringVar("meters")
	ir.RegisterCallback("calculate", func() {
		f, _ := strconv.Atof64(feet.Get())
		meters.Set(strconv.Ftoa64(f*0.3048, 'f', 3))
	})

	ir.Eval(`
wm title . "Feet to Meters"
grid [ttk::frame .c -padding "3 3 12 12"] -column 0 -row 0 -sticky nwes
grid columnconfigure . 0 -weight 1; grid rowconfigure . 0 -weight 1

grid [ttk::entry .c.feet -width 7 -textvariable feet] -column 2 -row 1 -sticky we
grid [ttk::label .c.meters -textvariable meters] -column 2 -row 2 -sticky we
grid [ttk::button .c.calc -text "Calculate" -command calculate] -column 3 -row 3 -sticky w

grid [ttk::label .c.flbl -text "feet"] -column 3 -row 1 -sticky w
grid [ttk::label .c.islbl -text "is equivalent to"] -column 1 -row 2 -sticky e
grid [ttk::label .c.mlbl -text "meters"] -column 3 -row 2 -sticky w

foreach w [winfo children .c] {grid configure $w -padx 5 -pady 5}
focus .c.feet
bind . <Return> {calculate}
	`)
	ir.MainLoop()
}
开发者ID:sebastianskejoe,项目名称:gothic,代码行数:32,代码来源:feettometers.go

示例8: _baseReadFloat

// Base to read float numbers.
func (q *Question) _baseReadFloat(prompt string, defaultAnswer float64, def hasDefault) (answer float64, err os.Error) {
	line := q.getLine(
		prompt,
		strconv.Ftoa64(defaultAnswer, QuestionFloatFmt, QuestionFloatPrec),
		def,
	)

	for {
		input, err := line.Read()
		if err != nil {
			return 0.0, err
		}
		if input == "" && def != _DEFAULT_NO {
			return defaultAnswer, nil
		}

		answer, err = strconv.Atof64(input)
		if err != nil {
			fmt.Fprintf(output, "%s%q: the value has to be a float\r\n",
				QuestionErrPrefix, input)
			continue
		} else {
			return answer, nil
		}
	}
	return
}
开发者ID:postfix,项目名称:go-linoise,代码行数:28,代码来源:question.go

示例9: valueToString

func valueToString(v reflect.Value) (string, os.Error) {
	if v == nil {
		return "null", nil
	}

	switch v := v.(type) {
	case *reflect.PtrValue:
		return valueToString(reflect.Indirect(v))
	case *reflect.InterfaceValue:
		return valueToString(v.Elem())
	case *reflect.BoolValue:
		x := v.Get()
		if x {
			return "true", nil
		} else {
			return "false", nil
		}

	case *reflect.IntValue:
		return strconv.Itoa(v.Get()), nil
	case *reflect.Int8Value:
		return strconv.Itoa(int(v.Get())), nil
	case *reflect.Int16Value:
		return strconv.Itoa(int(v.Get())), nil
	case *reflect.Int32Value:
		return strconv.Itoa(int(v.Get())), nil
	case *reflect.Int64Value:
		return strconv.Itoa64(v.Get()), nil

	case *reflect.UintValue:
		return strconv.Uitoa(v.Get()), nil
	case *reflect.Uint8Value:
		return strconv.Uitoa(uint(v.Get())), nil
	case *reflect.Uint16Value:
		return strconv.Uitoa(uint(v.Get())), nil
	case *reflect.Uint32Value:
		return strconv.Uitoa(uint(v.Get())), nil
	case *reflect.Uint64Value:
		return strconv.Uitoa64(v.Get()), nil
	case *reflect.UintptrValue:
		return strconv.Uitoa64(uint64(v.Get())), nil

	case *reflect.FloatValue:
		return strconv.Ftoa(v.Get(), 'g', -1), nil
	case *reflect.Float32Value:
		return strconv.Ftoa32(v.Get(), 'g', -1), nil
	case *reflect.Float64Value:
		return strconv.Ftoa64(v.Get(), 'g', -1), nil

	case *reflect.StringValue:
		return v.Get(), nil
	case *reflect.SliceValue:
		typ := v.Type().(*reflect.SliceType)
		if _, ok := typ.Elem().(*reflect.Uint8Type); ok {
			return string(v.Interface().([]byte)), nil
		}
	}
	return "", os.NewError("Unsupported type")
}
开发者ID:mikelikespie,项目名称:redis.go,代码行数:59,代码来源:redis.go

示例10: Zadd

func (client *Client) Zadd(key string, value []byte, score float64) (bool, os.Error) {
	res, err := client.sendCommand("ZADD", key, strconv.Ftoa64(score, 'f', -1), string(value))
	if err != nil {
		return false, err
	}

	return res.(int64) == 1, nil
}
开发者ID:alangenfeld,项目名称:flock,代码行数:8,代码来源:redis.go

示例11: Zremrangebyscore

func (client *Client) Zremrangebyscore(key string, start float64, end float64) (int, os.Error) {
	res, err := client.sendCommand("ZREMRANGEBYSCORE", key, strconv.Ftoa64(start, 'f', -1), strconv.Ftoa64(end, 'f', -1))
	if err != nil {
		return -1, err
	}

	return int(res.(int64)), nil
}
开发者ID:alangenfeld,项目名称:flock,代码行数:8,代码来源:redis.go

示例12: SetValue

func (ne *NumberEdit) SetValue(value float64) os.Error {
	text := strconv.Ftoa64(value, 'f', ne.Decimals())

	if err := ne.edit.SetText(text); err != nil {
		return err
	}

	return nil
}
开发者ID:wiloe,项目名称:walk,代码行数:9,代码来源:numberedit.go

示例13: Zincrby

func (client *Client) Zincrby(key string, value []byte, score float64) (float64, os.Error) {
	res, err := client.sendCommand("ZINCRBY", key, strconv.Ftoa64(score, 'f', -1), string(value))
	if err != nil {
		return 0, err
	}

	data := string(res.([]byte))
	f, _ := strconv.Atof64(data)
	return f, nil
}
开发者ID:alangenfeld,项目名称:flock,代码行数:10,代码来源:redis.go

示例14: main

func main() {
	ok := true
	for i := 0; i < len(tests); i++ {
		t := tests[i]
		v := strconv.Ftoa64(t.f, 'g', -1)
		if v != t.out {
			println("Bad float64 const:", t.in, "want", t.out, "got", v)
			x, err := strconv.Atof64(t.out)
			if err != nil {
				panicln("bug120: strconv.Atof64", t.out)
			}
			println("\twant exact:", strconv.Ftoa64(x, 'g', 1000))
			println("\tgot exact: ", strconv.Ftoa64(t.f, 'g', 1000))
			ok = false
		}
	}
	if !ok {
		os.Exit(1)
	}
}
开发者ID:8l,项目名称:go-learn,代码行数:20,代码来源:bug120.go

示例15: String

func (m *Mat3) String() string {
	s := "["
	for i := 0; i < 9; i += 1 {
		s += strconv.Ftoa64(m.matrix[i], 'e', 2)
		if i < 8 {
			s += ", "
		}
	}
	s += "]"
	return s
}
开发者ID:flameofwar,项目名称:s3dm-go,代码行数:11,代码来源:mat3.go


注:本文中的strconv.Ftoa64函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。