好好爱自己!

golang convert integer to float number

There is no float type. Looks like you want float64. You could also use float32 if you only need a single-precision floating point value.

package main

import "fmt"

func main() {
    i := 5
    f := float64(i)
    fmt.Printf("f is %f\n", f)
}
posted @ 2017-06-21 14:49  立志做一个好的程序员  阅读(386)  评论(0编辑  收藏  举报

不断学习创作,与自己快乐相处