How to convert int to float in Go

1 Answer

0 votes
package main

import (
	"fmt"
)

func main() {
    var i int64 = 2349 

    var f float64 = float64(i) 

    fmt.Println(f) 
    fmt.Printf("%.2f", f) 
  
}




/*
run:

2349
2349.00

*/

 



answered May 26, 2020 by avibootz

Related questions

1 answer 226 views
226 views asked Oct 17, 2020 by avibootz
1 answer 164 views
2 answers 92 views
92 views asked Oct 30, 2024 by avibootz
1 answer 104 views
1 answer 187 views
3 answers 229 views
229 views asked May 26, 2020 by avibootz
...