doulu3808 2013-10-07 16:41
浏览 616
已采纳

在Golang中将整数转换为浮点数

How do I convert an integer value to float64 type?

I tried

float(integer_value)

But this does not work. And can't find any package that does this on Golang.org

How do I get float64 values from integer values?

  • 写回答

4条回答 默认 最新

  • douhui4831 2013-10-07 16:44
    关注

    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
    ", f)
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 学习Python如何找兼职
  • ¥15 python结合Matlab仿真忆阻器
  • ¥35 有人会注册whatsaop协议号吗?
  • ¥15 lead dbs 无法导入影像数据
  • ¥15 多目标MPA算法优化编程实现
  • ¥15 反激PWM控制芯片调研
  • ¥15 Python for loop减少运行时间
  • ¥15 fluent模拟物质浓度udf
  • ¥15 Collection contains no element matching the predicate
  • ¥20 冻品电商平台的搜索是怎么实现的