Answers for "golang string contains int and string convert to float"

Go
2

golang convert string to float

const bitSize = 64 // Don't think about it to much. It's just 64 bits.
floatNum, err := strconv.ParseFloat("123.45", bitSize)
fmt.Println(fmt.Sprintf("%f", floatNum))
Posted by: Guest on June-12-2020
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

Code answers related to "golang string contains int and string convert to float"

Browse Popular Code Answers by Language