Answers for "go int to float"

Go
2

convert float to int golang

package main
import "fmt"
func main() {
  var x float64 = 5.7
  var y int = int(x)
  fmt.Println(y)  // outputs "5"
}
Posted by: Guest on August-11-2021
0

go convert floating point number, to a string, with decimal digits.

s := fmt.Sprintf("%.2f", x)
Posted by: Guest on February-24-2021
0

go convert a string (with decimals) to a floating point number.

f, err := strconv.ParseFloat(s, 64)
Posted by: Guest on February-24-2021

Browse Popular Code Answers by Language